netsurf: branch rjek/bloom updated. release/3.0-74-g0c45ed9

NetSurf Browser Project (Commit Mailer) no-reply at netsurf-browser.org
Thu May 16 17:24:04 BST 2013


Gitweb links:

...log http://git.netsurf-browser.org/netsurf.git/shortlog/0c45ed935d81d7df958604ae4df34fda7181fca8
...commit http://git.netsurf-browser.org/netsurf.git/commit/0c45ed935d81d7df958604ae4df34fda7181fca8
...tree http://git.netsurf-browser.org/netsurf.git/tree/0c45ed935d81d7df958604ae4df34fda7181fca8

The branch, rjek/bloom has been updated
       via  0c45ed935d81d7df958604ae4df34fda7181fca8 (commit)
      from  7d60132816341e15a853f2f66f06d0755d0f2daa (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=0c45ed935d81d7df958604ae4df34fda7181fca8
commit 0c45ed935d81d7df958604ae4df34fda7181fca8
Author: Rob Kendrick (humdrum) <rob.kendrick at codethink.co.uk>
Commit: Rob Kendrick (humdrum) <rob.kendrick at codethink.co.uk>

    Better bit and byte selection

diff --git a/utils/bloom.c b/utils/bloom.c
index e6b9dcf..1b07d6f 100644
--- a/utils/bloom.c
+++ b/utils/bloom.c
@@ -20,7 +20,6 @@
  * Trivial bloom filter */
 
 #include <stdlib.h>
-#include <stdio.h>
 #include "utils/bloom.h"
 
 /**
@@ -79,10 +78,11 @@ void bloom_insert_str(struct bloom_filter *b, const char *s, size_t z)
 
 void bloom_insert_hash(struct bloom_filter *b, uint32_t hash)
 {
-	int index = hash % b->size;
-	int bit = hash % 8;
+	unsigned int index = hash % (b->size << 3);
+	unsigned int byte_index = index >> 3;
+	unsigned int bit_index = index & 7;
 
-	b->filter[index] |= (1 << bit);
+	b->filter[byte_index] |= (1 << bit_index);
 	b->items++;
 }
 
@@ -94,10 +94,11 @@ bool bloom_search_str(struct bloom_filter *b, const char *s, size_t z)
 
 bool bloom_search_hash(struct bloom_filter *b, uint32_t hash)
 {
-	int index = hash % b->size;
-	int bit = hash % 8;	
+	unsigned int index = hash % (b->size << 3);
+	unsigned int byte_index = index >> 3;
+	unsigned int bit_index = index & 7;
 	
-	return (b->filter[index] & (1 << bit)) != 0;
+	return (b->filter[byte_index] & (1 << bit_index)) != 0;
 }
 
 uint32_t bloom_items(struct bloom_filter *b)


-----------------------------------------------------------------------

Summary of changes:
 utils/bloom.c |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/utils/bloom.c b/utils/bloom.c
index e6b9dcf..1b07d6f 100644
--- a/utils/bloom.c
+++ b/utils/bloom.c
@@ -20,7 +20,6 @@
  * Trivial bloom filter */
 
 #include <stdlib.h>
-#include <stdio.h>
 #include "utils/bloom.h"
 
 /**
@@ -79,10 +78,11 @@ void bloom_insert_str(struct bloom_filter *b, const char *s, size_t z)
 
 void bloom_insert_hash(struct bloom_filter *b, uint32_t hash)
 {
-	int index = hash % b->size;
-	int bit = hash % 8;
+	unsigned int index = hash % (b->size << 3);
+	unsigned int byte_index = index >> 3;
+	unsigned int bit_index = index & 7;
 
-	b->filter[index] |= (1 << bit);
+	b->filter[byte_index] |= (1 << bit_index);
 	b->items++;
 }
 
@@ -94,10 +94,11 @@ bool bloom_search_str(struct bloom_filter *b, const char *s, size_t z)
 
 bool bloom_search_hash(struct bloom_filter *b, uint32_t hash)
 {
-	int index = hash % b->size;
-	int bit = hash % 8;	
+	unsigned int index = hash % (b->size << 3);
+	unsigned int byte_index = index >> 3;
+	unsigned int bit_index = index & 7;
 	
-	return (b->filter[index] & (1 << bit)) != 0;
+	return (b->filter[byte_index] & (1 << bit_index)) != 0;
 }
 
 uint32_t bloom_items(struct bloom_filter *b)


-- 
NetSurf Browser



More information about the netsurf-commits mailing list