From 2dfa6f6033f762243f776025aeb7dbc2b383342b Mon Sep 17 00:00:00 2001 From: bfredl Date: Mon, 16 Sep 2024 19:28:37 +0200 Subject: refactor(multibyte): neo-casefolding without allocation fixes #30400 --- src/nvim/mbyte.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) (limited to 'src/nvim') diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index 05f81c48a9..01e720283e 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -1379,22 +1379,11 @@ int utf_fold(int a) return a; } - utf8proc_uint8_t input_str[16] = { 0 }; - if (utf8proc_encode_char(a, input_str) <= 0) { - return a; - } - - utf8proc_uint8_t *fold_str_utf; - if (utf8proc_map((utf8proc_uint8_t *)input_str, 0, &fold_str_utf, - UTF8PROC_NULLTERM | UTF8PROC_CASEFOLD) < 0) { - return a; - } - - int fold_codepoint_utf = utf_ptr2char((char *)fold_str_utf); + utf8proc_int32_t result[1]; - xfree(fold_str_utf); + utf8proc_ssize_t res = utf8proc_decompose_char(a, result, 1, UTF8PROC_CASEFOLD, NULL); - return fold_codepoint_utf; + return (res == 1) ? result[0] : a; } // Vim's own character class functions. These exist because many library -- cgit