Skip to content

Commit 46931d3

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d0229ab commit 46931d3

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

object.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ int type_from_string_gently(const char *str, ssize_t len, int gentle)
5959
* the specified sha1. n must be a power of 2. Please note that the
6060
* return value is *not* consistent across computer architectures.
6161
*/
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)
6363
{
64-
return sha1hash(sha1) & (n - 1);
64+
return sha1hash(oid->hash) & (n - 1);
6565
}
6666

6767
/*
@@ -71,7 +71,7 @@ static unsigned int hash_obj(const unsigned char *sha1, unsigned int n)
7171
*/
7272
static void insert_obj_hash(struct object *obj, struct object **hash, unsigned int size)
7373
{
74-
unsigned int j = hash_obj(obj->oid.hash, size);
74+
unsigned int j = hash_obj(&obj->oid, size);
7575

7676
while (hash[j]) {
7777
j++;
@@ -93,7 +93,7 @@ struct object *lookup_object(struct repository *r, const struct object_id *oid)
9393
if (!r->parsed_objects->obj_hash)
9494
return NULL;
9595

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);
9797
while ((obj = r->parsed_objects->obj_hash[i]) != NULL) {
9898
if (oideq(oid, &obj->oid))
9999
break;

0 commit comments

Comments
 (0)