diff options
author | brian m. carlson <sandals@crustytoothpaste.net> | 2017-03-26 18:01:37 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-03-28 18:59:34 +0200 |
commit | ee3051bd2307cdc0145aa9ed9dcacb8acfc08c40 (patch) | |
tree | 34c83024d11dbd1de894fc8d1e92a9714b30c463 /sha1-array.c | |
parent | builtin/pull: convert to struct object_id (diff) | |
download | git-ee3051bd2307cdc0145aa9ed9dcacb8acfc08c40.tar.xz git-ee3051bd2307cdc0145aa9ed9dcacb8acfc08c40.zip |
sha1-array: convert internal storage for struct sha1_array to object_id
Make the internal storage for struct sha1_array use an array of struct
object_id internally. Update the users of this struct which inspect its
internals.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sha1-array.c')
-rw-r--r-- | sha1-array.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/sha1-array.c b/sha1-array.c index c1cc25cd95..093d158003 100644 --- a/sha1-array.c +++ b/sha1-array.c @@ -4,39 +4,39 @@ void sha1_array_append(struct sha1_array *array, const unsigned char *sha1) { - ALLOC_GROW(array->sha1, array->nr + 1, array->alloc); - hashcpy(array->sha1[array->nr++], sha1); + ALLOC_GROW(array->oid, array->nr + 1, array->alloc); + hashcpy(array->oid[array->nr++].hash, sha1); array->sorted = 0; } static int void_hashcmp(const void *a, const void *b) { - return hashcmp(a, b); + return oidcmp(a, b); } static void sha1_array_sort(struct sha1_array *array) { - QSORT(array->sha1, array->nr, void_hashcmp); + QSORT(array->oid, array->nr, void_hashcmp); array->sorted = 1; } static const unsigned char *sha1_access(size_t index, void *table) { - unsigned char (*array)[20] = table; - return array[index]; + struct object_id *array = table; + return array[index].hash; } int sha1_array_lookup(struct sha1_array *array, const unsigned char *sha1) { if (!array->sorted) sha1_array_sort(array); - return sha1_pos(sha1, array->sha1, array->nr, sha1_access); + return sha1_pos(sha1, array->oid, array->nr, sha1_access); } void sha1_array_clear(struct sha1_array *array) { - free(array->sha1); - array->sha1 = NULL; + free(array->oid); + array->oid = NULL; array->nr = 0; array->alloc = 0; array->sorted = 0; @@ -53,9 +53,9 @@ int sha1_array_for_each_unique(struct sha1_array *array, for (i = 0; i < array->nr; i++) { int ret; - if (i > 0 && !hashcmp(array->sha1[i], array->sha1[i-1])) + if (i > 0 && !oidcmp(array->oid + i, array->oid + i - 1)) continue; - ret = fn(array->sha1[i], data); + ret = fn(array->oid[i].hash, data); if (ret) return ret; } |