From: Fabian Keil <fk@fabiankeil.de>
Date: Fri, 25 Sep 2020 15:22:03 +0000 (+0200)
Subject: pcrs: Request JIT compilation if it's supported
X-Git-Tag: v_3_0_29~60
X-Git-Url: http://www.privoxy.org/gitweb/%22https:/faq/developer-manual/man-page/static/gitweb.js?a=commitdiff_plain;h=36bed44da8971c4b75627ec86cc41163bfde81ae;p=privoxy.git

pcrs: Request JIT compilation if it's supported
---

diff --git a/pcrs.c b/pcrs.c
index 4a9e318d..67b7b356 100644
--- a/pcrs.c
+++ b/pcrs.c
@@ -471,7 +471,14 @@ pcrs_job *pcrs_free_job(pcrs_job *job)
    {
       next = job->next;
       if (job->pattern != NULL) free(job->pattern);
-      if (job->hints != NULL) free(job->hints);
+      if (job->hints != NULL)
+      {
+#ifdef PCRE_CONFIG_JIT
+         pcre_free_study(job->hints);
+#else
+         free(job->hints);
+#endif
+      }
       if (job->substitute != NULL)
       {
          if (job->substitute->text != NULL) free(job->substitute->text);
@@ -621,6 +628,7 @@ pcrs_job *pcrs_compile(const char *pattern, const char *substitute, const char *
    int flags;
    int capturecount;
    const char *error;
+   int pcre_study_options = 0;
 
    *errptr = 0;
 
@@ -660,11 +668,15 @@ pcrs_job *pcrs_compile(const char *pattern, const char *substitute, const char *
    }
 
 
+#ifdef PCRE_STUDY_JIT_COMPILE
+   pcre_study_options = PCRE_STUDY_JIT_COMPILE;
+#endif
+
    /*
     * Generate hints. This has little overhead, since the
     * hints will be NULL for a boring pattern anyway.
     */
-   newjob->hints = pcre_study(newjob->pattern, 0, &error);
+   newjob->hints = pcre_study(newjob->pattern, pcre_study_options, &error);
    if (error != NULL)
    {
       *errptr = PCRS_ERR_STUDY;