Faster return for wildmatch with trailing '*'.
authorDaniel Carl <danielcarl@gmx.de>
Fri, 5 Sep 2014 21:09:28 +0000 (23:09 +0200)
committerDaniel Carl <danielcarl@gmx.de>
Fri, 5 Sep 2014 21:09:28 +0000 (23:09 +0200)
If the pattern ends in '*' it's not necessary to call the wildmatch, because
this will match everything.

src/util.c

index 5c4a2ee..1084482 100644 (file)
@@ -542,8 +542,13 @@ gboolean util_wildmatch(const char *pattern, const char *string)
                 break;
 
             case '*':
+                /* easiest case - the '*' ist the last char in pattern - this
+                 * will always match */
+                if (*(p + 1) == '\0') {
+                    return true;
+                }
                 /* Try to match as much as possible. Try to match the complete
-                 * uri, if that fails move forward in uri and chack for a
+                 * uri, if that fails move forward in uri and check for a
                  * match. */
                 i = strlen(s);
                 while (i >= 0 && !util_wildmatch(p + 1, s + i)) {