patch 9.1.0409: too many strlen() calls in the regexp engine
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: #14648
Signed-off-by: John Marriott <basilisk@internode.on.net>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/regexp_nfa.c b/src/regexp_nfa.c
index 5e4fadd..4f07a21 100644
--- a/src/regexp_nfa.c
+++ b/src/regexp_nfa.c
@@ -5387,7 +5387,7 @@
rex.input = rex.line;
}
else
- rex.input = rex.line + STRLEN(rex.line);
+ rex.input = rex.line + reg_getline_len(rex.lnum);
}
if ((int)(rex.input - rex.line) >= state->val)
{
@@ -6937,8 +6937,7 @@
{
colnr_T pos_col = pos->lnum == rex.lnum + rex.reg_firstlnum
&& pos->col == MAXCOL
- ? (colnr_T)STRLEN(reg_getline(
- pos->lnum - rex.reg_firstlnum))
+ ? reg_getline_len(pos->lnum - rex.reg_firstlnum)
: pos->col;
result = (pos->lnum == rex.lnum + rex.reg_firstlnum