vim-patch:9.1.0426: too many strlen() calls in search.c

Problem:  too many strlen() calls in search.c
Solution: refactor code and remove more strlen() calls,
          use explicit variable to remember strlen
          (John Marriott)

closes: vim/vim#14796

8c85a2a49a

Co-authored-by: John Marriott <basilisk@internode.on.net>
This commit is contained in:
zeertzjq
2024-05-21 06:22:23 +08:00
parent 879d17ea8d
commit b86381f425
13 changed files with 279 additions and 194 deletions

View File

@@ -35,9 +35,10 @@ itp('pat_has_uppercase', function()
end)
describe('search_regcomp', function()
local search_regcomp = function(pat, pat_save, pat_use, options)
local search_regcomp = function(pat, patlen, pat_save, pat_use, options)
local regmatch = ffi.new('regmmatch_T')
local fail = search.search_regcomp(to_cstr(pat), nil, pat_save, pat_use, options, regmatch)
local fail =
search.search_regcomp(to_cstr(pat), patlen, nil, pat_save, pat_use, options, regmatch)
return fail, regmatch
end
@@ -50,7 +51,7 @@ describe('search_regcomp', function()
globals.curwin.w_onebuf_opt.wo_rl = 1
globals.curwin.w_onebuf_opt.wo_rlc = to_cstr('s')
globals.cmdmod.cmod_flags = globals.CMOD_KEEPPATTERNS
local fail = search_regcomp('a\192', 0, 0, 0)
local fail = search_regcomp('a\192', 2, 0, 0, 0)
eq(1, fail)
eq('\192a', get_search_pat())
end)