[Forensics-changes] [yara] 54/415: Small speed optimization
Hilko Bengen
bengen at moszumanska.debian.org
Thu Apr 3 05:42:44 UTC 2014
This is an automated email from the git hooks/post-receive script.
bengen pushed a commit to branch debian
in repository yara.
commit 225848400b8a028de0b8e1f5d7c1796ccb95a388
Author: Victor M. Alvarez <plusvic at gmail.com>
Date: Sun Dec 20 20:51:33 2009 +0000
Small speed optimization
---
libyara/scan.c | 24 +++---------------------
1 file changed, 3 insertions(+), 21 deletions(-)
diff --git a/libyara/scan.c b/libyara/scan.c
index 3b07401..8818aec 100644
--- a/libyara/scan.c
+++ b/libyara/scan.c
@@ -207,7 +207,7 @@ int hex_match(unsigned char* buffer, unsigned int buffer_size, unsigned char* pa
}
}
- else if ((buffer[b] & mask[m]) == pattern[p]) // TODO: This is the most common case, maybe could be checked first for speed optimization
+ else if ((buffer[b] & mask[m]) == pattern[p])
{
b++;
m++;
@@ -627,7 +627,6 @@ int find_matches_for_strings( STRING_LIST_ENTRY* first_string,
int negative_size)
{
int len;
- int overlap;
STRING* string;
MATCH* match;
@@ -645,25 +644,8 @@ int find_matches_for_strings( STRING_LIST_ENTRY* first_string,
for the string 'aa' and the file contains 'aaaaaa'.
*/
- overlap = FALSE;
-
- if (string->flags && STRING_FLAGS_FOUND)
- {
- match = string->matches;
-
- while(match != NULL) // TODO: Possible optimization: is enough to check the only last match instead of all the previous ones?
- {
- if (match->offset + match->length > current_file_offset)
- {
- overlap = TRUE;
- break;
- }
-
- match = match->next;
- }
- }
-
- if (!overlap)
+ if ((string->matches == NULL) ||
+ (string->matches->offset + string->matches->length <= current_file_offset))
{
string->flags |= STRING_FLAGS_FOUND;
match = (MATCH*) yr_malloc(sizeof(MATCH));
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/forensics/yara.git
More information about the forensics-changes
mailing list