From: Junio C Hamano Date: Thu, 11 Aug 2011 17:53:10 GMT Subject: [PATCH 05/11] object hash: we know the table size is a power of two Message-ID: <1313085196-13249-6-git-send-email-gitster@pobox.com> In-Reply-To: <1313085196-13249-1-git-send-email-gitster@pobox.com> Signed-off-by: Junio C Hamano --- object.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/object.c b/object.c index 259a67e..d95d7a6 100644 --- a/object.c +++ b/object.c @@ -52,7 +52,7 @@ static unsigned int hash_val(const unsigned char *sha1) static void insert_obj_hash(struct object *obj, struct object **hash, unsigned int size) { - unsigned int j = hash_val(obj->sha1) % size; + unsigned int j = hash_val(obj->sha1) & (size-1); while (hash[j]) { j++; @@ -70,7 +70,7 @@ struct object *lookup_object(const unsigned char *sha1) if (!obj_hash) return NULL; - i = hash_val(sha1) % obj_hash_size; + i = hash_val(sha1) & (obj_hash_size-1); while ((obj = obj_hash[i]) != NULL) { if (!hashcmp(sha1, obj->sha1)) break; -- 1.7.6.433.g1421f