LCOV - differential code coverage report
Current view: top level - contrib/ltree - crc32.c (source / functions) Coverage Total Hit GNC CBC DUB DCB
Current: 0e5ff9b9b45a657aea12440478dc002e9b01f138 vs 0123ce131fca454009439dfa3b2266d1d40737d7 Lines: 100.0 % 14 14 7 7 5 8
Current Date: 2026-03-14 14:10:32 -0400 Functions: 100.0 % 1 1 1
Baseline: lcov-20260315-024220-baseline Branches: 100.0 % 6 6 4 2 5 5
Baseline Date: 2026-03-14 15:27:56 +0100 Line coverage date bins:
Legend: Lines:     hit not hit
Branches: + taken - not taken # not executed
(30,360] days: 100.0 % 10 10 6 4
(360..) days: 100.0 % 4 4 1 3
Function coverage date bins:
(360..) days: 100.0 % 1 1 1
Branch coverage date bins:
(30,360] days: 100.0 % 4 4 2 2
(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
 2174 tgl@sss.pgh.pa.us          22                 :CBC      156217 : ltree_crc32_sz(const char *buf, int size)
                                 23                 :                : {
                                 24                 :                :     pg_crc32    crc;
                                 25                 :         156217 :     const char *p = buf;
   67 tmunro@postgresql.or       26                 :         156217 :     const char *end = buf + size;
                                 27                 :                :     static pg_locale_t locale = NULL;
                                 28                 :                : 
   89 jdavis@postgresql.or       29         [ +  + ]:         156217 :     if (!locale)
   89 jdavis@postgresql.or       30                 :GNC           1 :         locale = pg_database_locale();
                                 31                 :                : 
 4149 heikki.linnakangas@i       32                 :CBC      156217 :     INIT_TRADITIONAL_CRC32(crc);
 4149 heikki.linnakangas@i       33         [ +  + ]:GNC      374760 :     while (size > 0)
                                 34                 :                :     {
                                 35                 :                :         char        foldstr[UNICODE_CASEMAP_BUFSZ];
   67 tmunro@postgresql.or       36                 :         218543 :         int         srclen = pg_mblen_range(p, end);
                                 37                 :                :         size_t      foldlen;
                                 38                 :                : 
                                 39                 :                :         /* fold one codepoint at a time */
   89 jdavis@postgresql.or       40                 :         218543 :         foldlen = pg_strfold(foldstr, UNICODE_CASEMAP_BUFSZ, p, srclen,
                                 41                 :                :                              locale);
                                 42                 :                : 
                                 43         [ +  + ]:         437086 :         COMP_TRADITIONAL_CRC32(crc, foldstr, foldlen);
                                 44                 :                : 
                                 45                 :         218543 :         size -= srclen;
                                 46                 :         218543 :         p += srclen;
                                 47                 :                :     }
   89 jdavis@postgresql.or       48                 :CBC      156217 :     FIN_TRADITIONAL_CRC32(crc);
                                 49                 :         156217 :     return (unsigned int) crc;
                                 50                 :                : }
                                 51                 :                : 
                                 52                 :                : #else
                                 53                 :                : 
                                 54                 :                : unsigned int
                                 55                 :                : ltree_crc32_sz(const char *buf, int size)
                                 56                 :                : {
                                 57                 :                :     pg_crc32    crc;
                                 58                 :                :     const char *p = buf;
                                 59                 :                : 
                                 60                 :                :     INIT_TRADITIONAL_CRC32(crc);
                                 61                 :                :     while (size > 0)
                                 62                 :                :     {
                                 63                 :                :         COMP_TRADITIONAL_CRC32(crc, p, 1);
                                 64                 :                :         size--;
                                 65                 :                :         p++;
                                 66                 :                :     }
                                 67                 :                :     FIN_TRADITIONAL_CRC32(crc);
                                 68                 :                :     return (unsigned int) crc;
                                 69                 :                : }
                                 70                 :                : 
                                 71                 :                : #endif                          /* !LOWER_NODE */
        

Generated by: LCOV version 2.4-beta