File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change 290
290
local function re_match_compile (regex , opts )
291
291
local flags = 0
292
292
local pcre_opts = 0
293
+ local regex_match_tab
293
294
294
295
if opts then
295
296
flags , pcre_opts = parse_regex_opts (opts )
@@ -312,8 +313,11 @@ local function re_match_compile(regex, opts)
312
313
end
313
314
314
315
if compile_once then
315
- key = regex .. ' \0 ' .. opts
316
- compiled = lrucache_get (regex_match_cache , key )
316
+ local res = lrucache_get (regex_match_cache , regex )
317
+ if res ~= nil then
318
+ regex_match_tab = res
319
+ compiled = regex_match_tab [opts ]
320
+ end
317
321
end
318
322
319
323
-- compile the regex
@@ -335,8 +339,12 @@ local function re_match_compile(regex, opts)
335
339
-- print("ncaptures: ", compiled.ncaptures)
336
340
337
341
if compile_once then
342
+ if not regex_match_tab then
343
+ regex_match_tab = new_tab (0 , 4 )
344
+ end
345
+ regex_match_tab [opts ] = compiled
338
346
-- print("inserting compiled regex into cache")
339
- lrucache_set (regex_match_cache , key , compiled )
347
+ lrucache_set (regex_match_cache , regex , regex_match_tab )
340
348
end
341
349
end
342
350
You can’t perform that action at this time.
0 commit comments