Browse code

minor optimisation

git-svn: trunk@3220

Tomasz Kojm authored on 2007/09/15 04:04:14
Showing 2 changed files
... ...
@@ -1,3 +1,7 @@
1
+Fri Sep 14 20:16:20 CEST 2007 (tk)
2
+----------------------------------
3
+  * libclamav/matcher-ac.c: minor optimisation
4
+
1 5
 Fri Sep 14 10:03:22 BST 2007 (njh)
2 6
 ----------------------------------
3 7
   * libclamav/message.c:	--enable-debug: fix assertion (thanks to Edvin)
... ...
@@ -619,7 +619,7 @@ int cli_ac_addsig(struct cli_matcher *root, const char *virname, const char *hex
619 619
 	struct cli_ac_patt *new;
620 620
 	char *pt, *hex = NULL;
621 621
 	uint16_t i, j, ppos = 0, pend;
622
-	uint8_t wprefix = 0, error = 0, namelen, plen = 0;
622
+	uint8_t wprefix = 0, zprefix = 1, error = 0, namelen, plen = 0;
623 623
 	int ret;
624 624
 
625 625
 #define FREE_ALT			\
... ...
@@ -760,9 +760,11 @@ int cli_ac_addsig(struct cli_matcher *root, const char *virname, const char *hex
760 760
 	    wprefix = 1;
761 761
 	    break;
762 762
 	}
763
+	if(zprefix && new->pattern[i])
764
+	    zprefix = 0;
763 765
     }
764 766
 
765
-    if(wprefix) {
767
+    if(wprefix || zprefix) {
766 768
 	pend = new->length - root->ac_mindepth + 1;
767 769
 	for(i = 0; i < pend; i++) {
768 770
 	    for(j = i; j < i + root->ac_maxdepth && j < new->length; j++) {