diff --git a/slimt/Regex.cc b/slimt/Regex.cc index be1ad05e..33c85292 100644 --- a/slimt/Regex.cc +++ b/slimt/Regex.cc @@ -11,7 +11,7 @@ namespace slimt { -Regex::Regex(const std::string& pattern, uint32_t options) +Regex::Regex(const std::string& pattern, uint32_t options, uint32_t jit_options) : re_(pcre2_compile(PCRE2_SPTR(pattern.c_str()), /* the pattern */ PCRE2_ZERO_TERMINATED, /* pattern is zero-terminated */ options, /* options */ @@ -19,6 +19,12 @@ Regex::Regex(const std::string& pattern, uint32_t options) &error_offset_, /* for error offset */ nullptr)) /* use default compile context */ { + uint32_t have_jit; + pcre2_config(PCRE2_CONFIG_JIT, &have_jit); + if (have_jit) { + pcre2_jit_compile(re_, jit_options); + } + pattern_ = pattern; } diff --git a/slimt/Regex.hh b/slimt/Regex.hh index f55566b2..d0adac05 100644 --- a/slimt/Regex.hh +++ b/slimt/Regex.hh @@ -16,8 +16,9 @@ class Match; class Regex { public: Regex(const std::string& pattern, // pattern to be compiled - uint32_t options // pcre2 options for regex compilation - ); + uint32_t options, // pcre2 options for regex compilation + uint32_t jit_options = + PCRE2_JIT_COMPLETE); // options for jit compilation ~Regex(); int find(std::string_view subj, // the string (view) agains we are matching