LCOV - differential code coverage report
Current view: top level - contrib/ltree - crc32.c (source / functions) Coverage Total Hit UBC GNC CBC
Current: 1a1248818fb8b8b0353c292c632d6a6af77e8209 vs 8e82d6610e7280d7870c0c36ff1c797e3cfb3e09 Lines: 100.0 % 15 15 15
Current Date: 2026-10-12 11:56:10 +0200 Functions: 100.0 % 1 1 1
Baseline: lcov-20261012-baseline Branches: 87.5 % 8 7 1 7
Baseline Date: 2026-10-12 10:36:06 +0200 Line coverage date bins:
Legend: Lines:     hit not hit
Branches: + taken - not taken # not executed
(30,360] days: 100.0 % 11 11 11
(360..) days: 100.0 % 4 4 4
Function coverage date bins:
(360..) days: 100.0 % 1 1 1
Branch coverage date bins:
(30,360] days: 83.3 % 6 5 1 5
(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
 2385 tgl@sss.pgh.pa.us          22                 :CBC      173588 : ltree_crc32_sz(const char *buf, int size)
                                 23                 :                : {
                                 24                 :                :     pg_crc32    crc;
                                 25                 :         173588 :     const char *p = buf;
  278 tmunro@postgresql.or       26                 :         173588 :     const char *end = buf + size;
                                 27                 :                :     static pg_locale_t locale = NULL;
                                 28                 :                : 
  300 jdavis@postgresql.or       29         [ +  + ]:         173588 :     if (!locale)
                                 30                 :              1 :         locale = pg_database_locale();
                                 31                 :                : 
 4360 heikki.linnakangas@i       32                 :         173588 :     INIT_TRADITIONAL_CRC32(crc);
                                 33         [ +  + ]:         472931 :     while (size > 0)
                                 34                 :                :     {
                                 35                 :                :         /* max space required to map single codepoint, including NUL */
                                 36                 :                :         char        foldstr[PG_CASEMAP_BUFSZ];
  278 tmunro@postgresql.or       37                 :         299343 :         int         srclen = pg_mblen_range(p, end);
                                 38                 :                :         size_t      foldlen;
                                 39                 :                : 
                                 40                 :                :         /* fold one codepoint at a time */
   49 jdavis@postgresql.or       41                 :         299343 :         foldlen = pg_strfold(foldstr, sizeof(foldstr), p, srclen, locale);
                                 42         [ -  + ]:         299343 :         Assert(foldlen < sizeof(foldstr));
                                 43                 :                : 
  300                            44         [ +  + ]:         598686 :         COMP_TRADITIONAL_CRC32(crc, foldstr, foldlen);
                                 45                 :                : 
                                 46                 :         299343 :         size -= srclen;
                                 47                 :         299343 :         p += srclen;
                                 48                 :                :     }
                                 49                 :         173588 :     FIN_TRADITIONAL_CRC32(crc);
                                 50                 :         173588 :     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