LCOV - differential code coverage report
Current view: top level - contrib/ltree - crc32.c (source / functions) Coverage Total Hit UBC GNC CBC
Current: ba12a202ce1b5581dc0ed149cf3f637d7897ad5d vs 2866d8c7dbfc9d882a7d80fef93fbbe763709932 Lines: 100.0 % 15 15 15
Current Date: 2026-08-27 14:31:44 +0300 Functions: 100.0 % 1 1 1
Baseline: lcov-20260827-baseline Branches: 87.5 % 8 7 1 7
Baseline Date: 2026-08-27 14:31:58 +0300 Line coverage date bins:
Legend: Lines:     hit not hit
Branches: + taken - not taken # not executed
(1,7] days: 100.0 % 2 2 2
(30,360] days: 100.0 % 9 9 9
(360..) days: 100.0 % 4 4 4
Function coverage date bins:
(360..) days: 100.0 % 1 1 1
Branch coverage date bins:
(1,7] days: 50.0 % 2 1 1 1
(30,360] days: 100.0 % 4 4 4
(360..) days: 100.0 % 2 2 2

 Age         Owner                    Branch data    TLA  Line data    Source code
                                  1                 :                : /* contrib/ltree/crc32.c */
                                  2                 :                : 
                                  3                 :                : /*
                                  4                 :                :  * Implements CRC-32, as used in ltree.
                                  5                 :                :  *
                                  6                 :                :  * Note that the CRC is used in the on-disk format of GiST indexes, so we
                                  7                 :                :  * must stay backwards-compatible!
                                  8                 :                :  */
                                  9                 :                : 
                                 10                 :                : #include "postgres.h"
                                 11                 :                : #include "ltree.h"
                                 12                 :                : 
                                 13                 :                : #include "crc32.h"
                                 14                 :                : #include "utils/pg_crc.h"
                                 15                 :                : #ifdef LOWER_NODE
                                 16                 :                : #include "utils/pg_locale.h"
                                 17                 :                : #endif
                                 18                 :                : 
                                 19                 :                : #ifdef LOWER_NODE
                                 20                 :                : 
                                 21                 :                : unsigned int
 2339 tgl@sss.pgh.pa.us          22                 :CBC      172777 : ltree_crc32_sz(const char *buf, int size)
                                 23                 :                : {
                                 24                 :                :     pg_crc32    crc;
                                 25                 :         172777 :     const char *p = buf;
  232 tmunro@postgresql.or       26                 :         172777 :     const char *end = buf + size;
                                 27                 :                :     static pg_locale_t locale = NULL;
                                 28                 :                : 
  254 jdavis@postgresql.or       29         [ +  + ]:         172777 :     if (!locale)
                                 30                 :              1 :         locale = pg_database_locale();
                                 31                 :                : 
 4314 heikki.linnakangas@i       32                 :         172777 :     INIT_TRADITIONAL_CRC32(crc);
                                 33         [ +  + ]:         470855 :     while (size > 0)
                                 34                 :                :     {
                                 35                 :                :         /* max space required to map single codepoint, including NUL */
                                 36                 :                :         char        foldstr[PG_CASEMAP_BUFSZ];
  232 tmunro@postgresql.or       37                 :         298078 :         int         srclen = pg_mblen_range(p, end);
                                 38                 :                :         size_t      foldlen;
                                 39                 :                : 
                                 40                 :                :         /* fold one codepoint at a time */
    3 jdavis@postgresql.or       41                 :         298078 :         foldlen = pg_strfold(foldstr, sizeof(foldstr), p, srclen, locale);
                                 42         [ -  + ]:         298078 :         Assert(foldlen < sizeof(foldstr));
                                 43                 :                : 
  254                            44         [ +  + ]:         596156 :         COMP_TRADITIONAL_CRC32(crc, foldstr, foldlen);
                                 45                 :                : 
                                 46                 :         298078 :         size -= srclen;
                                 47                 :         298078 :         p += srclen;
                                 48                 :                :     }
                                 49                 :         172777 :     FIN_TRADITIONAL_CRC32(crc);
                                 50                 :         172777 :     return (unsigned int) crc;
                                 51                 :                : }
                                 52                 :                : 
                                 53                 :                : #else
                                 54                 :                : 
                                 55                 :                : unsigned int
                                 56                 :                : ltree_crc32_sz(const char *buf, int size)
                                 57                 :                : {
                                 58                 :                :     pg_crc32    crc;
                                 59                 :                :     const char *p = buf;
                                 60                 :                : 
                                 61                 :                :     INIT_TRADITIONAL_CRC32(crc);
                                 62                 :                :     while (size > 0)
                                 63                 :                :     {
                                 64                 :                :         COMP_TRADITIONAL_CRC32(crc, p, 1);
                                 65                 :                :         size--;
                                 66                 :                :         p++;
                                 67                 :                :     }
                                 68                 :                :     FIN_TRADITIONAL_CRC32(crc);
                                 69                 :                :     return (unsigned int) crc;
                                 70                 :                : }
                                 71                 :                : 
                                 72                 :                : #endif                          /* !LOWER_NODE */
        

Generated by: LCOV version 2.0-1