]> git.ipfire.org Git - pakfire.git/commitdiff
parser: Use JIT for PCRE2
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 3 Mar 2021 15:01:28 +0000 (15:01 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 3 Mar 2021 15:01:28 +0000 (15:01 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/parser.c

index f0a952b2217c188236b7f68b3a61e93d6ad68993..6411d8ff8a55df271485b04acb27551ab9bf1a7d 100644 (file)
@@ -64,6 +64,14 @@ static int pakfire_parser_compile_regex(PakfireParser parser) {
 
                        return 1;
                }
+
+               // Enable JIT
+               pcre2_errno = pcre2_jit_compile(parser->regex_variable, PCRE2_JIT_COMPLETE);
+               if (pcre2_errno) {
+                       pcre2_get_error_message(pcre2_errno, errmsg, sizeof(errmsg));
+                       ERROR(parser->pakfire, "Enabling JIT on variables failed: %s\n", errmsg);
+                       return 1;
+               }
        }
 
        return 0;
@@ -367,8 +375,8 @@ static int pakfire_parser_expand_variables(PakfireParser parser,
        // Search for any variables
        while (1) {
                // Perform matching
-               int r = pcre2_match(parser->regex_variable, (PCRE2_UCHAR*)*buffer, strlen(*buffer),
-                       0, 0, match, NULL);
+               int r = pcre2_jit_match(parser->regex_variable,
+                       (PCRE2_UCHAR*)*buffer, strlen(*buffer), 0, 0, match, NULL);
 
                // End loop when we have expanded all variables
                if (r == PCRE2_ERROR_NOMATCH) {