Browse code

libclamav/matcher-bm.c: minor performance improvement (bb#1539)

git-svn: trunk@5034

Tomasz Kojm authored on 2009/04/10 21:01:57
Showing 3 changed files
... ...
@@ -1,3 +1,8 @@
1
+Fri Apr 10 14:01:01 CEST 2009 (tk)
2
+----------------------------------
3
+ * libclamav/matcher-bm.c: minor performance improvement (bb#1539)
4
+			   Thanks to Edwin
5
+
1 6
 Wed Apr  8 16:49:32 CEST 2009 (tk)
2 7
 ----------------------------------
3 8
  * V 0.95.1
... ...
@@ -74,7 +74,7 @@ int cli_bm_addpatt(struct cli_matcher *root, struct cli_bm_patt *pattern)
74 74
 
75 75
     prev = next = root->bm_suffix[idx];
76 76
     while(next) {
77
-	if(pt[0] >= next->pattern[0])
77
+	if(pt[0] >= next->pattern0)
78 78
 	    break;
79 79
 	prev = next;
80 80
 	next = next->next;
... ...
@@ -89,6 +89,7 @@ int cli_bm_addpatt(struct cli_matcher *root, struct cli_bm_patt *pattern)
89 89
 	pattern->next = prev->next;
90 90
 	prev->next = pattern;
91 91
     }
92
+    pattern->pattern0 = pattern->pattern[0];
92 93
     root->bm_suffix[idx]->cnt++;
93 94
 
94 95
     root->bm_patterns++;
... ...
@@ -173,7 +174,7 @@ int cli_bm_scanbuff(const unsigned char *buffer, uint32_t length, const char **v
173 173
 	    p = root->bm_suffix[idx];
174 174
 	    pchain = 0;
175 175
 	    while(p) {
176
-		if(p->pattern[0] != prefix) {
176
+		if(p->pattern0 != prefix) {
177 177
 		    if(pchain)
178 178
 			break;
179 179
 		    p = p->next;
... ...
@@ -31,6 +31,7 @@ struct cli_bm_patt {
31 31
     struct cli_bm_patt *next;
32 32
     uint16_t length, prefix_length;
33 33
     uint16_t cnt;
34
+    unsigned char pattern0;
34 35
     uint8_t target;
35 36
 };
36 37