svn commit: r226174 - user/gabor/tre-integration/contrib/tre/lib
Gabor Kovesdan
gabor at FreeBSD.org
Sun Oct 9 20:58:02 UTC 2011
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;
More information about the svn-src-user
mailing list