]> git.ipfire.org Git - thirdparty/git.git/commit - pack-bitmap.c
pack-bitmap: use object_id when loading on-disk bitmaps
authorJeff King <peff@peff.net>
Mon, 24 Feb 2020 04:32:27 +0000 (23:32 -0500)
committerJunio C Hamano <gitster@pobox.com>
Mon, 24 Feb 2020 20:55:53 +0000 (12:55 -0800)
commit500e4f236606684467b0b34b86e319dfa40747c4
tree8a1b6e6a668a609c28937c9dcddb71269412fbfc
parentf66d4e025059b734ba8da40ec059bb0fb8991306
pack-bitmap: use object_id when loading on-disk bitmaps

A pack bitmap file contains the index position of the commit for each
bitmap, which we then translate into an object id via
nth_packed_object_sha1(). In preparation for that function going away,
we can switch to the more type-safe nth_packed_object_id().

Note that even though the result ends up in an object_id this does incur
an extra copy of the hash (into our temporary object_id, and then into
the final malloc'd stored_bitmap struct). This shouldn't make any
measurable difference. If it did, we could avoid this copy _and_ the
copy of the rest of the items by allocating the stored_bitmap struct
beforehand and reading directly into it from the bitmap file. Or better
still, if this is a bottleneck, we could introduce an on-disk index to
the bitmap file so we don't have to read every single entry to use just
one of them. So it's not worth worrying about micro-optimizing out this
one hash copy.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
pack-bitmap.c