Enable JIT in PCRE to improve regular expressions performance

This commit is contained in:
Pavel Roschin 2016-09-22 00:13:01 +03:00
commit 61755945d2
2 changed files with 13 additions and 3 deletions

View file

@ -432,7 +432,12 @@ proc initRegex(pattern: string, flags: int, study = true): Regex =
if study:
# XXX investigate JIT
result.pcreExtra = pcre.study(result.pcreObj, 0x0, addr errorMsg)
var options: cint = 0
var hasJit: cint
if pcre.config(pcre.CONFIG_JIT, addr hasJit) == 0:
if hasJit == 1'i32:
options = pcre.STUDY_JIT_COMPILE
result.pcreExtra = pcre.study(result.pcreObj, options, addr errorMsg)
if errorMsg != nil:
raise StudyError(msg: $errorMsg)