aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/strings.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-05-20 12:42:57 +0800
committerGitHub <noreply@github.com>2024-05-20 12:42:57 +0800
commit0e187fe038c76e822353e7fb0fd96e860e5ab3ef (patch)
treea187736890a077f6468f14633dc64fe26e734560 /src/nvim/strings.c
parentb16b287b8f36a8e25b27f3009d7fdd0d39348894 (diff)
downloadrneovim-0e187fe038c76e822353e7fb0fd96e860e5ab3ef.tar.gz
rneovim-0e187fe038c76e822353e7fb0fd96e860e5ab3ef.tar.bz2
rneovim-0e187fe038c76e822353e7fb0fd96e860e5ab3ef.zip
vim-patch:9.1.0409: too many strlen() calls in the regexp engine (#28857)
Problem: too many strlen() calls in the regexp engine Solution: refactor code to retrieve strlen differently, make use of bsearch() for getting the character class (John Marriott) closes: vim/vim#14648 https://github.com/vim/vim/commit/82792db6315f7c7b0e299cdde1566f2932a463f8 Cherry-pick keyvalue_T and its comparison functions from patch 9.1.0256. vim-patch:9.1.0410: warning about uninitialized variable vim-patch:9.1.0412: typo in regexp_bt.c in DEBUG code Co-authored-by: John Marriott <basilisk@internode.on.net>
Diffstat (limited to 'src/nvim/strings.c')
-rw-r--r--src/nvim/strings.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/nvim/strings.c b/src/nvim/strings.c
index cc61b24f16..16ae35272b 100644
--- a/src/nvim/strings.c
+++ b/src/nvim/strings.c
@@ -3128,3 +3128,39 @@ void f_trim(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
}
rettv->vval.v_string = xstrnsave(head, (size_t)(tail - head));
}
+
+/// compare two keyvalue_T structs by case sensitive value
+int cmp_keyvalue_value(const void *a, const void *b)
+{
+ keyvalue_T *kv1 = (keyvalue_T *)a;
+ keyvalue_T *kv2 = (keyvalue_T *)b;
+
+ return strcmp(kv1->value, kv2->value);
+}
+
+/// compare two keyvalue_T structs by value with length
+int cmp_keyvalue_value_n(const void *a, const void *b)
+{
+ keyvalue_T *kv1 = (keyvalue_T *)a;
+ keyvalue_T *kv2 = (keyvalue_T *)b;
+
+ return strncmp(kv1->value, kv2->value, MAX(kv1->length, kv2->length));
+}
+
+/// compare two keyvalue_T structs by case insensitive value
+int cmp_keyvalue_value_i(const void *a, const void *b)
+{
+ keyvalue_T *kv1 = (keyvalue_T *)a;
+ keyvalue_T *kv2 = (keyvalue_T *)b;
+
+ return STRICMP(kv1->value, kv2->value);
+}
+
+/// compare two keyvalue_T structs by case insensitive value with length
+int cmp_keyvalue_value_ni(const void *a, const void *b)
+{
+ keyvalue_T *kv1 = (keyvalue_T *)a;
+ keyvalue_T *kv2 = (keyvalue_T *)b;
+
+ return STRNICMP(kv1->value, kv2->value, MAX(kv1->length, kv2->length));
+}