[Forensics-changes] [yara] 187/415: Small speed optimization

Hilko Bengen bengen at moszumanska.debian.org
Thu Apr 3 05:43:03 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 d4f841093eee015f96d6642b92480f9c9c15d240
Author: Victor M. Alvarez <plusvic at gmail.com>
Date:   Mon Jul 1 11:53:20 2013 +0000

    Small speed optimization
---
 libyara/arena.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/libyara/arena.c b/libyara/arena.c
index 3bae40f..d33074c 100644
--- a/libyara/arena.c
+++ b/libyara/arena.c
@@ -111,6 +111,17 @@ ARENA_PAGE* _yr_arena_page_for_address(
 {
   ARENA_PAGE* page;
 
+  // Most of the times this function is called with an address within
+  // the current page, let's check the current page first to avoid
+  // looping through the page list.
+
+  page = arena->current_page;
+
+  if (page != NULL &&
+      (uint8_t*) address >= page->address &&
+      (uint8_t*) address < page->address + page->used)
+    return page;
+
   page = arena->page_list_head;
 
   while (page != NULL)

-- 
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