summaryrefslogtreecommitdiff
path: root/oid-array.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2021-01-28 06:19:42 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-01-28 20:02:39 (GMT)
commit45ee13b942b26925b33d827bda2856e1ed0af0b7 (patch)
tree87f89914fdf93c8d3ef42411657c668680ccadcf /oid-array.c
parent680ff910b0329c8482f98ad9d3c49f4628c1bafa (diff)
downloadgit-45ee13b942b26925b33d827bda2856e1ed0af0b7.zip
git-45ee13b942b26925b33d827bda2856e1ed0af0b7.tar.gz
git-45ee13b942b26925b33d827bda2856e1ed0af0b7.tar.bz2
hash_pos(): convert to oid_pos()
All of our callers are actually looking up an object_id, not a bare hash. Likewise, the arrays they are looking in are actual arrays of object_id (not just raw bytes of hashes, as we might find in a pack .idx; those are handled by bsearch_hash()). Using an object_id gives us more type safety, and makes the callers slightly shorter. It also gets rid of the word "sha1" from several access functions, though we could obviously also rename those with s/sha1/hash/. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'oid-array.c')
-rw-r--r--oid-array.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/oid-array.c b/oid-array.c
index 889b311..a19235a 100644
--- a/oid-array.c
+++ b/oid-array.c
@@ -22,16 +22,16 @@ void oid_array_sort(struct oid_array *array)
array->sorted = 1;
}
-static const unsigned char *sha1_access(size_t index, void *table)
+static const struct object_id *oid_access(size_t index, void *table)
{
struct object_id *array = table;
- return array[index].hash;
+ return &array[index];
}
int oid_array_lookup(struct oid_array *array, const struct object_id *oid)
{
oid_array_sort(array);
- return hash_pos(oid->hash, array->oid, array->nr, sha1_access);
+ return oid_pos(oid, array->oid, array->nr, oid_access);
}
void oid_array_clear(struct oid_array *array)