Coverage Report

Created: 2025-08-23 06:26

/src/libunistring/lib/uninorm/decomposition-table.h
Line
Count
Source
1
/* Decomposition of Unicode characters.
2
   Copyright (C) 2001-2003, 2009-2025 Free Software Foundation, Inc.
3
   Written by Bruno Haible <bruno@clisp.org>, 2009.
4
5
   This file is free software: you can redistribute it and/or modify
6
   it under the terms of the GNU Lesser General Public License as
7
   published by the Free Software Foundation; either version 2.1 of the
8
   License, or (at your option) any later version.
9
10
   This file is distributed in the hope that it will be useful,
11
   but WITHOUT ANY WARRANTY; without even the implied warranty of
12
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
   GNU Lesser General Public License for more details.
14
15
   You should have received a copy of the GNU Lesser General Public License
16
   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
17
18
19
#include "unitypes.h"
20
21
/* The decomposition table is made of two parts:
22
     - A table containing the actual arrays of decomposed equivalents.
23
       (This table is separate because the maximum length of a decomposition
24
       is 18, much larger than the average length 1.497 of a decomposition).
25
     - A 3-level table of indices into this array.  */
26
27
#include "decomposition-table1.h"
28
29
static inline unsigned short
30
decomp_index (ucs4_t uc)
31
46.6M
{
32
46.6M
  unsigned int index1 = uc >> decomp_header_0;
33
46.6M
  if (index1 < decomp_header_1)
34
46.6M
    {
35
46.6M
      int lookup1 = gl_uninorm_decomp_index_table.level1[index1];
36
46.6M
      if (lookup1 >= 0)
37
46.2M
        {
38
46.2M
          unsigned int index2 = (uc >> decomp_header_2) & decomp_header_3;
39
46.2M
          int lookup2 = gl_uninorm_decomp_index_table.level2[lookup1 + index2];
40
46.2M
          if (lookup2 >= 0)
41
15.3M
            {
42
15.3M
              unsigned int index3 = uc & decomp_header_4;
43
15.3M
              return gl_uninorm_decomp_index_table.level3[lookup2 + index3];
44
15.3M
            }
45
46.2M
        }
46
46.6M
    }
47
31.2M
  return (unsigned short)(-1);
48
46.6M
}
decomposition.c:decomp_index
Line
Count
Source
31
28.1M
{
32
28.1M
  unsigned int index1 = uc >> decomp_header_0;
33
28.1M
  if (index1 < decomp_header_1)
34
28.1M
    {
35
28.1M
      int lookup1 = gl_uninorm_decomp_index_table.level1[index1];
36
28.1M
      if (lookup1 >= 0)
37
27.9M
        {
38
27.9M
          unsigned int index2 = (uc >> decomp_header_2) & decomp_header_3;
39
27.9M
          int lookup2 = gl_uninorm_decomp_index_table.level2[lookup1 + index2];
40
27.9M
          if (lookup2 >= 0)
41
9.78M
            {
42
9.78M
              unsigned int index3 = uc & decomp_header_4;
43
9.78M
              return gl_uninorm_decomp_index_table.level3[lookup2 + index3];
44
9.78M
            }
45
27.9M
        }
46
28.1M
    }
47
18.3M
  return (unsigned short)(-1);
48
28.1M
}
Unexecuted instantiation: decomposition-table.c:decomp_index
canonical-decomposition.c:decomp_index
Line
Count
Source
31
18.5M
{
32
18.5M
  unsigned int index1 = uc >> decomp_header_0;
33
18.5M
  if (index1 < decomp_header_1)
34
18.5M
    {
35
18.5M
      int lookup1 = gl_uninorm_decomp_index_table.level1[index1];
36
18.5M
      if (lookup1 >= 0)
37
18.2M
        {
38
18.2M
          unsigned int index2 = (uc >> decomp_header_2) & decomp_header_3;
39
18.2M
          int lookup2 = gl_uninorm_decomp_index_table.level2[lookup1 + index2];
40
18.2M
          if (lookup2 >= 0)
41
5.59M
            {
42
5.59M
              unsigned int index3 = uc & decomp_header_4;
43
5.59M
              return gl_uninorm_decomp_index_table.level3[lookup2 + index3];
44
5.59M
            }
45
18.2M
        }
46
18.5M
    }
47
12.9M
  return (unsigned short)(-1);
48
18.5M
}