object: convert internal hash_obj() to object_id
Now that lookup_object() has an object_id, we can consistently pass that around instead of a raw sha1. We still convert to a hash to pass to sha1hash(), but the goal is for that to go away shortly. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Jun 20, 2019 at 03:41 UTC
46931d39389f2886e6c159674923345f024e1c64
1 file changed
+4
-4
object.c
+4
-4
@@ -59,9 +59,9 @@ int type_from_string_gently(const char *str, ssize_t len, int gentle)
59
* the specified sha1. n must be a power of 2. Please note that the
60
* return value is *not* consistent across computer architectures.
61
*/
62
-static unsigned int hash_obj(const unsigned char *sha1, unsigned int n)
62
+static unsigned int hash_obj(const struct object_id *oid, unsigned int n)
63
{
64
- return sha1hash(sha1) & (n - 1);
64
+ return sha1hash(oid->hash) & (n - 1);
65
}
66
67
/*
@@ -71,7 +71,7 @@ static unsigned int hash_obj(const unsigned char *sha1, unsigned int n)
71
*/
72
static void insert_obj_hash(struct object *obj, struct object **hash, unsigned int size)
73
{
74
- unsigned int j = hash_obj(obj->oid.hash, size);
74
+ unsigned int j = hash_obj(&obj->oid, size);
75
76
while (hash[j]) {
77
j++;
@@ -93,7 +93,7 @@ struct object *lookup_object(struct repository *r, const struct object_id *oid)
93
if (!r->parsed_objects->obj_hash)
94
return NULL;
95
96
- first = i = hash_obj(oid->hash, r->parsed_objects->obj_hash_size);
96
+ first = i = hash_obj(oid, r->parsed_objects->obj_hash_size);
97
while ((obj = r->parsed_objects->obj_hash[i]) != NULL) {
98
if (oideq(oid, &obj->oid))
99
break;