diff options
author | Derrick Stolee <dstolee@microsoft.com> | 2018-03-22 18:40:09 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-03-22 19:00:07 +0100 |
commit | 3d475f46a8225a9cc549ac5cb2c51d6ecd9e0f7c (patch) | |
tree | 09459e67cb30070c566ceebc78d6a2b26547dc66 /packfile.h | |
parent | sha1_name: convert struct min_abbrev_data to object_id (diff) | |
download | git-3d475f46a8225a9cc549ac5cb2c51d6ecd9e0f7c.tar.xz git-3d475f46a8225a9cc549ac5cb2c51d6ecd9e0f7c.zip |
packfile: define and use bsearch_pack()
The method bsearch_hash() generalizes binary searches using a
fanout table. The only consumer is currently find_pack_entry_one().
It requires a bit of pointer arithmetic to align the fanout table
and the lookup table depending on the pack-index version.
Extract the pack-index pointer arithmetic to a new method,
bsearch_pack(), so this can be re-used in other code paths.
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'packfile.h')
-rw-r--r-- | packfile.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/packfile.h b/packfile.h index a7fca598d6..ec08cb2bb0 100644 --- a/packfile.h +++ b/packfile.h @@ -79,6 +79,14 @@ extern struct packed_git *add_packed_git(const char *path, size_t path_len, int extern void check_pack_index_ptr(const struct packed_git *p, const void *ptr); /* + * Perform binary search on a pack-index for a given oid. Packfile is expected to + * have a valid pack-index. + * + * See 'bsearch_hash' for more information. + */ +int bsearch_pack(const struct object_id *oid, const struct packed_git *p, uint32_t *result); + +/* * Return the SHA-1 of the nth object within the specified packfile. * Open the index if it is not already open. The return value points * at the SHA-1 within the mmapped index. Return NULL if there is an |