From owner-svn-src-user@FreeBSD.ORG Sun Oct 9 20:58:02 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 80EEB106566C; Sun, 9 Oct 2011 20:58:02 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 712588FC14; Sun, 9 Oct 2011 20:58:02 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p99Kw2ax026486; Sun, 9 Oct 2011 20:58:02 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p99Kw27i026484; Sun, 9 Oct 2011 20:58:02 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201110092058.p99Kw27i026484@svn.freebsd.org> From: Gabor Kovesdan Date: Sun, 9 Oct 2011 20:58:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r226174 - user/gabor/tre-integration/contrib/tre/lib X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 Oct 2011 20:58:02 -0000 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;