patch 9.2.1043: matchlist() allocates empty strings for unmatched submatches
Commit:
https://github.com/vim/vim/commit/d6b449ade472f011f6779d23341cdad8ff91f438
Author: Julien Voisin <
julien...@dustri.org>
Date: Mon Sep 7 20:26:22 2026 +0000
patch 9.2.1043: matchlist() allocates empty strings for unmatched submatches
Problem: matchlist() always returns a List of ten items, allocating an
empty string for every unmatched submatch even though a NULL
string behaves identically.
Solution: Append a NULL string instead of an allocated empty string for
unmatched submatches, saving up to nine allocations per call.
Real-world patterns with one to three groups run about 3 to 5 percent faster.
Since matchlist is usually used in loops iterating on a whole buffer, I think
it's a worthwhile optimization.
closes: #21238
Signed-off-by: Julien Voisin <
julien...@dustri.org>
Signed-off-by: Christian Brabandt <
c...@256bit.org>
diff --git a/src/evalfunc.c b/src/evalfunc.c
index fce9ec796..c0c9a38ee 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -9300,7 +9300,7 @@ find_some_match(typval_T *argvars, typval_T *rettv, matchtype_T type)
if (regmatch.endp[i] == NULL)
{
if (list_append_string(rettv->vval.v_list,
- (char_u *)"", 0) == FAIL)
+ NULL, 0) == FAIL)
break;
}
else if (list_append_string(rettv->vval.v_list,
diff --git a/src/version.c b/src/version.c
index 6752df82b..b884a80f3 100644
--- a/src/version.c
+++ b/src/version.c
@@ -763,6 +763,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1043,
/**/
1042,
/**/