Skip to content

Commit

Permalink
module: unicode: remove unused tolower transformations
Browse files Browse the repository at this point in the history
With the previous patch this yields
  $ size -G ./module/zfs.ko ./module/zfs.new.ko
        text       data        bss      total filename
     2865126    1597982     755768    5218876 ./module/zfs.ko
     2864038    1429784     755768    5049590 ./module/zfs.new.ko
       -1088    -168198
         -1k      -164k

Signed-off-by: Ahelenia Ziemiańska <[email protected]>
  • Loading branch information
nabijaczleweli committed Oct 30, 2024
1 parent 488abfe commit b437865
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 6 deletions.
4 changes: 4 additions & 0 deletions include/sys/u8_textprep.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ extern "C" {
*/
#define U8_STRCMP_CS (0x00000001)
#define U8_STRCMP_CI_UPPER (0x00000002)
#if 0
#define U8_STRCMP_CI_LOWER (0x00000004)
#endif

#define U8_CANON_DECOMP (0x00000010)
#define U8_COMPAT_DECOMP (0x00000020)
Expand All @@ -57,7 +59,9 @@ extern "C" {
#define U8_STRCMP_NFKC (U8_COMPAT_DECOMP | U8_CANON_COMP)

#define U8_TEXTPREP_TOUPPER (U8_STRCMP_CI_UPPER)
#ifdef U8_STRCMP_CI_LOWER
#define U8_TEXTPREP_TOLOWER (U8_STRCMP_CI_LOWER)
#endif

#define U8_TEXTPREP_NFD (U8_STRCMP_NFD)
#define U8_TEXTPREP_NFC (U8_STRCMP_NFC)
Expand Down
2 changes: 2 additions & 0 deletions include/sys/u8_textprep_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -27630,6 +27630,7 @@ static const uchar_t u8_case_common_b2_tbl[U8_UNICODE_LATEST + 1][2][256] = {

};

#ifdef U8_STRCMP_CI_LOWER
static const u8_displacement_t u8_tolower_b3_tbl[U8_UNICODE_LATEST + 1][5][256] = {

Check failure on line 27634 in include/sys/u8_textprep_data.h

View workflow job for this annotation

GitHub Actions / checkstyle

line > 80 characters
#ifdef U8_UNICODE_320
{
Expand Down Expand Up @@ -31412,6 +31413,7 @@ static const uchar_t u8_tolower_final_tbl[U8_UNICODE_LATEST + 1][2299] = {
0x90, 0x91, 0x8F,
},
};
#endif

static const u8_displacement_t u8_toupper_b3_tbl[U8_UNICODE_LATEST + 1][5][256] = {

Check failure on line 31418 in include/sys/u8_textprep_data.h

View workflow job for this annotation

GitHub Actions / checkstyle

line > 80 characters
#ifdef U8_UNICODE_320
Expand Down
36 changes: 30 additions & 6 deletions module/unicode/u8_textprep.c
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,9 @@ do_case_conv(int uv, uchar_t *u8s, uchar_t *s, int sz, boolean_t is_it_toupper)

for (i = 0; start_id < end_id; start_id++)
u8s[i++] = u8_toupper_final_tbl[uv][b3_base + start_id];
} else {
}
#ifdef U8_STRCMP_CI_LOWER
else {
b3_tbl = u8_tolower_b3_tbl[uv][b2][b3].tbl_id;
if (b3_tbl == U8_TBL_ELEMENT_NOT_DEF)
return ((size_t)sz);
Expand All @@ -547,6 +549,7 @@ do_case_conv(int uv, uchar_t *u8s, uchar_t *s, int sz, boolean_t is_it_toupper)
for (i = 0; start_id < end_id; start_id++)
u8s[i++] = u8_tolower_final_tbl[uv][b3_base + start_id];
}
#endif

/*
* If i is still zero, that means there is no corresponding character.
Expand Down Expand Up @@ -1758,7 +1761,11 @@ do_norm_compare(size_t uv, uchar_t *s1, uchar_t *s2, size_t n1, size_t n2,
s2last = s2 + n2;

is_it_toupper = flag & U8_TEXTPREP_TOUPPER;
#ifdef U8_STRCMP_CI_LOWER
is_it_tolower = flag & U8_TEXTPREP_TOLOWER;
#else
is_it_tolower = 0;
#endif
canonical_decomposition = flag & U8_CANON_DECOMP;
compatibility_decomposition = flag & U8_COMPAT_DECOMP;
canonical_composition = flag & U8_CANON_COMP;
Expand Down Expand Up @@ -1875,12 +1882,18 @@ u8_strcmp(const char *s1, const char *s2, size_t n, int flag, size_t uv,
if (flag == 0) {
flag = U8_STRCMP_CS;
} else {
f = flag & (U8_STRCMP_CS | U8_STRCMP_CI_UPPER |
U8_STRCMP_CI_LOWER);
f = flag & (U8_STRCMP_CS | U8_STRCMP_CI_UPPER
#ifdef U8_STRCMP_CI_LOWER
| U8_STRCMP_CI_LOWER
#endif
);

Check failure on line 1889 in module/unicode/u8_textprep.c

View workflow job for this annotation

GitHub Actions / checkstyle

whitespace before right paren
if (f == 0) {
flag |= U8_STRCMP_CS;
} else if (f != U8_STRCMP_CS && f != U8_STRCMP_CI_UPPER &&
f != U8_STRCMP_CI_LOWER) {
} else if (f != U8_STRCMP_CS && f != U8_STRCMP_CI_UPPER
#ifdef U8_STRCMP_CI_LOWER
&& f != U8_STRCMP_CI_LOWER

Check failure on line 1894 in module/unicode/u8_textprep.c

View workflow job for this annotation

GitHub Actions / checkstyle

improper boolean continuation
#endif
) {
*errnum = EBADF;
flag = U8_STRCMP_CS;
}
Expand Down Expand Up @@ -1913,10 +1926,13 @@ u8_strcmp(const char *s1, const char *s2, size_t n, int flag, size_t uv,
if (flag == U8_STRCMP_CI_UPPER) {
return (do_case_compare(uv, (uchar_t *)s1, (uchar_t *)s2,
n1, n2, B_TRUE, errnum));
} else if (flag == U8_STRCMP_CI_LOWER) {
}
#ifdef U8_STRCMP_CI_LOWER
else if (flag == U8_STRCMP_CI_LOWER) {
return (do_case_compare(uv, (uchar_t *)s1, (uchar_t *)s2,
n1, n2, B_FALSE, errnum));
}
#endif

return (do_norm_compare(uv, (uchar_t *)s1, (uchar_t *)s2, n1, n2,
flag, errnum));
Expand Down Expand Up @@ -1950,11 +1966,15 @@ u8_textprep_str(char *inarray, size_t *inlen, char *outarray, size_t *outlen,
return ((size_t)-1);
}

#ifdef U8_TEXTPREP_TOLOWER
f = flag & (U8_TEXTPREP_TOUPPER | U8_TEXTPREP_TOLOWER);
if (f == (U8_TEXTPREP_TOUPPER | U8_TEXTPREP_TOLOWER)) {
*errnum = EBADF;
return ((size_t)-1);
}
#else
f = flag & U8_TEXTPREP_TOUPPER;
#endif

f = flag & (U8_CANON_DECOMP | U8_COMPAT_DECOMP | U8_CANON_COMP);
if (f && f != U8_TEXTPREP_NFD && f != U8_TEXTPREP_NFC &&
Expand All @@ -1979,7 +1999,11 @@ u8_textprep_str(char *inarray, size_t *inlen, char *outarray, size_t *outlen,
do_not_ignore_null = !(flag & U8_TEXTPREP_IGNORE_NULL);
do_not_ignore_invalid = !(flag & U8_TEXTPREP_IGNORE_INVALID);
is_it_toupper = flag & U8_TEXTPREP_TOUPPER;
#ifdef U8_TEXTPREP_TOLOWER
is_it_tolower = flag & U8_TEXTPREP_TOLOWER;
#else
is_it_tolower = 0;
#endif

ret_val = 0;

Expand Down

0 comments on commit b437865

Please sign in to comment.