Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 9 Oct 2011 20:58:02 +0000 (UTC)
From:      Gabor Kovesdan <gabor@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r226174 - user/gabor/tre-integration/contrib/tre/lib
Message-ID:  <201110092058.p99Kw27i026484@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: gabor
Date: Sun Oct  9 20:58:02 2011
New Revision: 226174
URL: http://svn.freebsd.org/changeset/base/226174

Log:
  - Only compile a heuristic if the shortcut failed

Modified:
  user/gabor/tre-integration/contrib/tre/lib/tre-compile.c

Modified: user/gabor/tre-integration/contrib/tre/lib/tre-compile.c
==============================================================================
--- user/gabor/tre-integration/contrib/tre/lib/tre-compile.c	Sun Oct  9 20:27:20 2011	(r226173)
+++ user/gabor/tre-integration/contrib/tre/lib/tre-compile.c	Sun Oct  9 20:58:02 2011	(r226174)
@@ -2279,25 +2279,31 @@ tre_compile(regex_t *preg, const tre_cha
 
   /*
    * If we reach here, the regex is parsed and legal. Now we try to construct
-   * a heuristic to speed up matching.
+   * a heuristic to speed up matching if we do not already have a shortcut
+   * pattern.
    */
-  heur = xmalloc(sizeof(heur_t));
-  if (!heur)
-    ERROR_EXIT(REG_ESPACE);
-
-  ret = tre_compile_heur(heur, regex, n, cflags);
-  if (ret != REG_OK)
+  if (!preg->shortcut)
     {
-      xfree(heur);
-      preg->heur = NULL;
-      DPRINT("tre_compile: heuristic compilation failed, NFA will be used "
-	     "entirely\n");
+      heur = xmalloc(sizeof(heur_t));
+      if (!heur)
+	ERROR_EXIT(REG_ESPACE);
+
+      ret = tre_compile_heur(heur, regex, n, cflags);
+      if (ret != REG_OK)
+	{
+	  xfree(heur);
+	  preg->heur = NULL;
+	  DPRINT("tre_compile: heuristic compilation failed, NFA will be used "
+		 "entirely\n");
+	}
+      else
+	{
+	  preg->heur = heur;
+	  DPRINT("tre_compile: heuristic compiled to speed up the search\n");
+	}
     }
   else
-    {
-      preg->heur = heur;
-      DPRINT("tre_compile: heuristic compiled to speed up the search\n");
-    }
+    preg->heur = NULL;
 
   return REG_OK;
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201110092058.p99Kw27i026484>