From 0dcb30e75c79900d90874eb098fbec67ef0c703b Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 5 Sep 2008 20:29:03 +0000 Subject: Optimized matchString for the common case where there is a trailing * (if that is the case, abort immediately instead of scanning the rest of the string) svn-id: r34367 --- common/str.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'common') diff --git a/common/str.cpp b/common/str.cpp index b2c9a7cdbf..a415e376c9 100644 --- a/common/str.cpp +++ b/common/str.cpp @@ -605,13 +605,18 @@ bool matchString(const char *str, const char *pat) { for (;;) { switch (*pat) { case '*': + // Record pattern / string possition for backtracking p = ++pat; q = str; + // If pattern ended with * -> match + if (!*pat) + return true; break; default: if (*pat != *str) { if (p) { + // No match, oops -> try to backtrack pat = p; str = ++q; if (!*str) -- cgit v1.2.3