LCOV - differential code coverage report
Current view: top level - contrib/ltree - crc32.c (source / functions) Coverage Total Hit UBC GNC CBC
Current: f76c13edadc2b319036e0d238703ed56bb23f934 vs 9e17d25e79d4756be08b4a5521b4b58450217137 Lines: 100.0 % 15 15 15
Current Date: 2026-09-20 14:13:17 +0900 Functions: 100.0 % 1 1 1
Baseline: lcov-20260920-baseline Branches: 87.5 % 8 7 1 7
Baseline Date: 2026-09-20 14:13:13 +0900 Line coverage date bins:
Legend: Lines:     hit not hit
Branches: + taken - not taken # not executed
(7,30] 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:
(7,30] 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
 2363 tgl@sss.pgh.pa.us          22                 :CBC      172713 : ltree_crc32_sz(const char *buf, int size)
                                 23                 :                : {
                                 24                 :                :     pg_crc32    crc;
                                 25                 :         172713 :     const char *p = buf;
  256 tmunro@postgresql.or       26                 :         172713 :     const char *end = buf + size;
                                 27                 :                :     static pg_locale_t locale = NULL;
                                 28                 :                : 
  278 jdavis@postgresql.or       29         [ +  + ]:         172713 :     if (!locale)
                                 30                 :              1 :         locale = pg_database_locale();
                                 31                 :                : 
 4338 heikki.linnakangas@i       32                 :         172713 :     INIT_TRADITIONAL_CRC32(crc);
                                 33         [ +  + ]:         470762 :     while (size > 0)
                                 34                 :                :     {
                                 35                 :                :         /* max space required to map single codepoint, including NUL */
                                 36                 :                :         char        foldstr[PG_CASEMAP_BUFSZ];
  256 tmunro@postgresql.or       37                 :         298049 :         int         srclen = pg_mblen_range(p, end);
                                 38                 :                :         size_t      foldlen;
                                 39                 :                : 
                                 40                 :                :         /* fold one codepoint at a time */
   27 jdavis@postgresql.or       41                 :         298049 :         foldlen = pg_strfold(foldstr, sizeof(foldstr), p, srclen, locale);
                                 42         [ -  + ]:         298049 :         Assert(foldlen < sizeof(foldstr));
                                 43                 :                : 
  278                            44         [ +  + ]:         596098 :         COMP_TRADITIONAL_CRC32(crc, foldstr, foldlen);
                                 45                 :                : 
                                 46                 :         298049 :         size -= srclen;
                                 47                 :         298049 :         p += srclen;
                                 48                 :                :     }
                                 49                 :         172713 :     FIN_TRADITIONAL_CRC32(crc);
                                 50                 :         172713 :     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