[PATCH 10/11] object: try 3-way cuckoo
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
../+v/48b49262cd2d0d64696b489fe5bdfa8efb9180f5/git-pack-objects
Counting objects: 2139209, done.
30.68user 2.26system 0:33.05elapsed 99%CPU (0avgtext+0avgdata 3660832maxresident)k
0inputs+0outputs (0major+421963minor)pagefaults 0swaps
Counting objects: 2139209, done.
30.76user 2.26system 0:33.12elapsed 99%CPU (0avgtext+0avgdata 3660480maxresident)k
0inputs+0outputs (0major+421941minor)pagefaults 0swaps
Counting objects: 2139209, done.
30.74user 2.33system 0:33.18elapsed 99%CPU (0avgtext+0avgdata 3661696maxresident)k
0inputs+0outputs (0major+422017minor)pagefaults 0swaps
---
object.c | 15 ++++-----------
1 files changed, 4 insertions(+), 11 deletions(-)
diff --git a/object.c b/object.c
index caced56..18e6bcf 100644
--- a/object.c
+++ b/object.c
@@ -49,20 +49,18 @@ struct object *get_indexed_object(unsigned int idx)
struct object *lookup_object(const unsigned char *sha1)
{
struct object *obj;
- unsigned int hashval[4];
+ unsigned int hashval[3];
if (!obj_hash)
return NULL;
- memcpy(hashval, sha1, 16);
+ memcpy(hashval, sha1, 12);
if ((obj = obj_hash[H(hashval, 0)]) && !hashcmp(sha1, obj->sha1))
return obj;
if ((obj = obj_hash[H(hashval, 1)]) && !hashcmp(sha1, obj->sha1))
return obj;
if ((obj = obj_hash[H(hashval, 2)]) && !hashcmp(sha1, obj->sha1))
return obj;
- if ((obj = obj_hash[H(hashval, 3)]) && !hashcmp(sha1, obj->sha1))
- return obj;
return NULL;
}
@@ -82,9 +80,9 @@ static struct object *insert_obj_hash(struct object *obj)
for (loop = obj_hash_size / 2; 0 <= loop; loop--) {
struct object *tmp_obj;
unsigned int ix;
- unsigned int hashval[4];
+ unsigned int hashval[3];
- memcpy(hashval, obj->sha1, 16);
+ memcpy(hashval, obj->sha1, 12);
ix = H(hashval, 0);
if (!obj_hash[ix]) {
obj_hash[ix] = obj;
@@ -96,11 +94,6 @@ static struct object *insert_obj_hash(struct object *obj)
return NULL;
}
ix = H(hashval, 2);
- if (!obj_hash[ix]) {
- obj_hash[ix] = obj;
- return NULL;
- }
- ix = H(hashval, 3);
tmp_obj = obj_hash[ix];
obj_hash[ix] = obj;
if (!tmp_obj)
--
1.7.6.433.g1421f