Coverage Report

Created: 2023-06-07 07:18

/src/libunistring/lib/uninorm/decomposition-table.h
Line
Count
Source
1
/* Decomposition of Unicode characters.
2
   Copyright (C) 2001-2003, 2009-2023 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
57.6M
{
32
57.6M
  unsigned int index1 = uc >> decomp_header_0;
33
57.6M
  if (index1 < decomp_header_1)
34
57.6M
    {
35
57.6M
      int lookup1 = gl_uninorm_decomp_index_table.level1[index1];
36
57.6M
      if (lookup1 >= 0)
37
57.4M
        {
38
57.4M
          unsigned int index2 = (uc >> decomp_header_2) & decomp_header_3;
39
57.4M
          int lookup2 = gl_uninorm_decomp_index_table.level2[lookup1 + index2];
40
57.4M
          if (lookup2 >= 0)
41
19.8M
            {
42
19.8M
              unsigned int index3 = uc & decomp_header_4;
43
19.8M
              return gl_uninorm_decomp_index_table.level3[lookup2 + index3];
44
19.8M
            }
45
57.4M
        }
46
57.6M
    }
47
37.8M
  return (unsigned short)(-1);
48
57.6M
}
canonical-decomposition.c:decomp_index
Line
Count
Source
31
20.9M
{
32
20.9M
  unsigned int index1 = uc >> decomp_header_0;
33
20.9M
  if (index1 < decomp_header_1)
34
20.9M
    {
35
20.9M
      int lookup1 = gl_uninorm_decomp_index_table.level1[index1];
36
20.9M
      if (lookup1 >= 0)
37
20.8M
        {
38
20.8M
          unsigned int index2 = (uc >> decomp_header_2) & decomp_header_3;
39
20.8M
          int lookup2 = gl_uninorm_decomp_index_table.level2[lookup1 + index2];
40
20.8M
          if (lookup2 >= 0)
41
6.55M
            {
42
6.55M
              unsigned int index3 = uc & decomp_header_4;
43
6.55M
              return gl_uninorm_decomp_index_table.level3[lookup2 + index3];
44
6.55M
            }
45
20.8M
        }
46
20.9M
    }
47
14.4M
  return (unsigned short)(-1);
48
20.9M
}
decomposition.c:decomp_index
Line
Count
Source
31
36.6M
{
32
36.6M
  unsigned int index1 = uc >> decomp_header_0;
33
36.6M
  if (index1 < decomp_header_1)
34
36.6M
    {
35
36.6M
      int lookup1 = gl_uninorm_decomp_index_table.level1[index1];
36
36.6M
      if (lookup1 >= 0)
37
36.6M
        {
38
36.6M
          unsigned int index2 = (uc >> decomp_header_2) & decomp_header_3;
39
36.6M
          int lookup2 = gl_uninorm_decomp_index_table.level2[lookup1 + index2];
40
36.6M
          if (lookup2 >= 0)
41
13.3M
            {
42
13.3M
              unsigned int index3 = uc & decomp_header_4;
43
13.3M
              return gl_uninorm_decomp_index_table.level3[lookup2 + index3];
44
13.3M
            }
45
36.6M
        }
46
36.6M
    }
47
23.3M
  return (unsigned short)(-1);
48
36.6M
}
Unexecuted instantiation: decomposition-table.c:decomp_index