Message ID | bc67bb462ae0c87b34e46568d54b170a8aec870b.1610129796.git.me@ttaylorr.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | pack-revindex: prepare for on-disk reverse index | expand |
On Fri, Jan 08, 2021 at 01:17:09PM -0500, Taylor Blau wrote: > diff --git a/pack-bitmap.c b/pack-bitmap.c > index d6861ddd4d..80c57bde73 100644 > --- a/pack-bitmap.c > +++ b/pack-bitmap.c > @@ -711,21 +711,22 @@ static void show_objects_for_type( > > for (offset = 0; offset < BITS_IN_EWORD; ++offset) { > struct object_id oid; > - struct revindex_entry *entry; > - uint32_t hash = 0; > + uint32_t hash = 0, n; > + off_t ofs; A minor nit, but "n" isn't very descriptive. It's not in scope for very long, so that's not too bad, but there are two positions at work in this function: the pos/offset bit position, and the index position. Maybe "index_pos" would be better than "n" to keep the two clear? -Peff
On Tue, Jan 12, 2021 at 03:57:59AM -0500, Jeff King wrote: > A minor nit, but "n" isn't very descriptive. It's not in scope for very > long, so that's not too bad, but there are two positions at work in this > function: the pos/offset bit position, and the index position. Maybe > "index_pos" would be better than "n" to keep the two clear? Much clearer, thank you. > -Peff Thanks, Taylor
diff --git a/pack-bitmap.c b/pack-bitmap.c index d6861ddd4d..80c57bde73 100644 --- a/pack-bitmap.c +++ b/pack-bitmap.c @@ -711,21 +711,22 @@ static void show_objects_for_type( for (offset = 0; offset < BITS_IN_EWORD; ++offset) { struct object_id oid; - struct revindex_entry *entry; - uint32_t hash = 0; + uint32_t hash = 0, n; + off_t ofs; if ((word >> offset) == 0) break; offset += ewah_bit_ctz64(word >> offset); - entry = &bitmap_git->pack->revindex[pos + offset]; - nth_packed_object_id(&oid, bitmap_git->pack, entry->nr); + n = pack_pos_to_index(bitmap_git->pack, pos + offset); + ofs = pack_pos_to_offset(bitmap_git->pack, pos + offset); + nth_packed_object_id(&oid, bitmap_git->pack, n); if (bitmap_git->hashes) - hash = get_be32(bitmap_git->hashes + entry->nr); + hash = get_be32(bitmap_git->hashes + n); - show_reach(&oid, object_type, 0, hash, bitmap_git->pack, entry->offset); + show_reach(&oid, object_type, 0, hash, bitmap_git->pack, ofs); } } }
Avoid storing the revindex entry directly, since this structure will soon be removed from the public interface. Instead, store the offset and index position by calling 'pack_pos_to_offset()' and 'pack_pos_to_index()', respectively. Signed-off-by: Taylor Blau <me@ttaylorr.com> --- pack-bitmap.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)