Browse code

minor optimisation

git-svn: trunk@3251

Tomasz Kojm authored on 2007/09/27 07:18:44
Showing 3 changed files
... ...
@@ -1,3 +1,7 @@
1
+Wed Sep 26 23:36:06 CEST 2007 (tk)
2
+----------------------------------
3
+  * libclamav/matcher-ac.c: minor optimisation
4
+
1 5
 Tue Sep 25 10:43:35 BST 2007 (njh)
2 6
 ----------------------------------
3 7
   * libclamav/mbox.c:	Only use strcasestr on Linux (for now, until it
... ...
@@ -331,6 +331,14 @@ void cli_ac_free(struct cli_matcher *root)
331 331
 
332 332
 #define AC_MATCH_CHAR(p,b)						\
333 333
     switch(wc = p & CLI_MATCH_WILDCARD) {				\
334
+	case CLI_MATCH_CHAR:						\
335
+	    if((unsigned char) p != b)					\
336
+		return 0;						\
337
+	    break;							\
338
+									\
339
+	case CLI_MATCH_IGNORE:						\
340
+	    break;							\
341
+									\
334 342
 	case CLI_MATCH_ALTERNATIVE:					\
335 343
 	    found = 0;							\
336 344
 	    for(j = 0; j < pattern->altn[alt]; j++) {			\
... ...
@@ -355,8 +363,8 @@ void cli_ac_free(struct cli_matcher *root)
355 355
 	    break;							\
356 356
 									\
357 357
 	default:							\
358
-	    if(wc != CLI_MATCH_IGNORE && (unsigned char) p != b)	\
359
-		return 0;						\
358
+	    cli_errmsg("ac_findmatch: Unknown wildcard 0x%x\n", wc);	\
359
+	    return 0;							\
360 360
     }
361 361
 
362 362
 inline static int ac_findmatch(const unsigned char *buffer, uint32_t offset, uint32_t length, const struct cli_ac_patt *pattern)
... ...
@@ -32,6 +32,7 @@
32 32
 #include "matcher-bm.h"
33 33
 
34 34
 #define CLI_MATCH_WILDCARD	0xff00
35
+#define CLI_MATCH_CHAR		0x0000
35 36
 #define CLI_MATCH_IGNORE	0x0100
36 37
 #define CLI_MATCH_ALTERNATIVE	0x0200
37 38
 #define CLI_MATCH_NIBBLE_HIGH	0x0300