From 83c8bb09bb92ba5d6cdfdbc75d0a6d9944cfa5d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Wed, 30 Oct 2024 12:58:12 +0100 Subject: [PATCH] module: unicode: remove unused tolower transformations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- include/sys/u8_textprep.h | 4 ++++ include/sys/u8_textprep_data.h | 2 ++ module/unicode/u8_textprep.c | 38 ++++++++++++++++++++++++++++------ 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/include/sys/u8_textprep.h b/include/sys/u8_textprep.h index 774bde75d642..3903938ade6f 100644 --- a/include/sys/u8_textprep.h +++ b/include/sys/u8_textprep.h @@ -67,7 +67,9 @@ extern int uconv_u8tou32(const uchar_t *, size_t *, uint32_t *, size_t *, int); */ #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) @@ -79,7 +81,9 @@ extern int uconv_u8tou32(const uchar_t *, size_t *, uint32_t *, size_t *, int); #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) diff --git a/include/sys/u8_textprep_data.h b/include/sys/u8_textprep_data.h index 39139540a8d1..bd6af0e8f661 100644 --- a/include/sys/u8_textprep_data.h +++ b/include/sys/u8_textprep_data.h @@ -27638,6 +27638,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] = { @@ -31422,6 +31423,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] = diff --git a/module/unicode/u8_textprep.c b/module/unicode/u8_textprep.c index 49e22c88cde7..a1742572909b 100644 --- a/module/unicode/u8_textprep.c +++ b/module/unicode/u8_textprep.c @@ -526,7 +526,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); @@ -542,6 +544,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. @@ -1753,7 +1756,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; @@ -1870,12 +1877,22 @@ 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); +#ifdef U8_STRCMP_CI_LOWER + f = flag & (U8_STRCMP_CS | U8_STRCMP_CI_UPPER + | U8_STRCMP_CI_LOWER); +#else + f = flag & (U8_STRCMP_CS | U8_STRCMP_CI_UPPER); +#endif if (f == 0) { flag |= U8_STRCMP_CS; - } else if (f != U8_STRCMP_CS && f != U8_STRCMP_CI_UPPER && - f != U8_STRCMP_CI_LOWER) { + } +#ifdef U8_STRCMP_CI_LOWER + else if (f != U8_STRCMP_CS && f != U8_STRCMP_CI_UPPER && + f != U8_STRCMP_CI_LOWER) +#else + else if (f != U8_STRCMP_CS && f != U8_STRCMP_CI_UPPER) +#endif + { *errnum = EBADF; flag = U8_STRCMP_CS; } @@ -1908,10 +1925,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)); @@ -1945,11 +1965,13 @@ 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); } +#endif f = flag & (U8_CANON_DECOMP | U8_COMPAT_DECOMP | U8_CANON_COMP); if (f && f != U8_TEXTPREP_NFD && f != U8_TEXTPREP_NFC && @@ -1974,7 +1996,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;