java/src/org/openantivirus/engine/credo WildcardPattern.java,1.1,1.2
Kurt Huwig <[email protected]> Wed, 26 May 2004 20:08:50 +0000
| Newsgroups | gmane.comp.security.virus.openantivirus.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/openantivirus/java/src/org/openantivirus/engine/credo
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14318/src/org/openantivirus/engine/credo
Modified Files:
WildcardPattern.java
Log Message:
Speed improvement: bytes in pattern file are now compared against a sequence of hex digits instead of substring()ed and parsed
Index: WildcardPattern.java
===================================================================
RCS file: /cvsroot/openantivirus/java/src/org/openantivirus/engine/credo/WildcardPattern.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- WildcardPattern.java 18 May 2004 09:03:30 -0000 1.1
+++ WildcardPattern.java 26 May 2004 20:08:47 -0000 1.2
@@ -39,6 +39,8 @@
public final byte[] pattern;
public final int[] skipList;
+ private final String HEXDIGITS = "0123456789ABCDEF";
+
public WildcardPattern(String hex) {
if (hex.length() % 2 != 0) {
throw new IllegalArgumentException("Malformed hexstring: " + hex);
@@ -51,8 +53,9 @@
int skipCount = 0;
boolean skip = false;
for (int i = 0; i < hex.length(); i += 2) {
- final String character = hex.substring(i, i + 2);
- if (character.equals("??")) {
+ final char c1 = hex.charAt(i);
+ final char c2 = hex.charAt(i + 1);
+ if (c1 == '?' && c2 == '?') {
if (skip) {
skipCount++;
} else {
@@ -68,7 +71,8 @@
colSkipList.add(new Integer(skipCount));
skipCount = 1;
}
- pattern[i / 2] = (byte) Integer.parseInt(character, 16);
+ pattern[i / 2] = (byte) ((HEXDIGITS.indexOf(c1) << 4)
+ + HEXDIGITS.indexOf(c2));
}
}
-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g.
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click