Skip to content

Commit 011f3fd

Browse files
ttaylorrgitster
authored andcommitted
try_partial_reuse(): convert to new revindex API
Remove another instance of direct revindex manipulation by calling 'pack_pos_to_offset()' instead (the caller here does not care about the index position of the object at position 'pos'). Note that we cannot just use the existing "offset" variable to store the value we get from pack_pos_to_offset(). It is incremented by unpack_object_header(), but we later need the original value. Since we'll no longer have revindex->offset to read it from, we'll store that in a separate variable ("header" since it points to the entry's header bytes). Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a78a903 commit 011f3fd

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

pack-bitmap.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,23 +1069,21 @@ static void try_partial_reuse(struct bitmap_index *bitmap_git,
10691069
struct bitmap *reuse,
10701070
struct pack_window **w_curs)
10711071
{
1072-
struct revindex_entry *revidx;
1073-
off_t offset;
1072+
off_t offset, header;
10741073
enum object_type type;
10751074
unsigned long size;
10761075

10771076
if (pos >= bitmap_git->pack->num_objects)
10781077
return; /* not actually in the pack */
10791078

1080-
revidx = &bitmap_git->pack->revindex[pos];
1081-
offset = revidx->offset;
1079+
offset = header = pack_pos_to_offset(bitmap_git->pack, pos);
10821080
type = unpack_object_header(bitmap_git->pack, w_curs, &offset, &size);
10831081
if (type < 0)
10841082
return; /* broken packfile, punt */
10851083

10861084
if (type == OBJ_REF_DELTA || type == OBJ_OFS_DELTA) {
10871085
off_t base_offset;
1088-
int base_pos;
1086+
uint32_t base_pos;
10891087

10901088
/*
10911089
* Find the position of the base object so we can look it up
@@ -1096,11 +1094,10 @@ static void try_partial_reuse(struct bitmap_index *bitmap_git,
10961094
* more detail.
10971095
*/
10981096
base_offset = get_delta_base(bitmap_git->pack, w_curs,
1099-
&offset, type, revidx->offset);
1097+
&offset, type, header);
11001098
if (!base_offset)
11011099
return;
1102-
base_pos = find_revindex_position(bitmap_git->pack, base_offset);
1103-
if (base_pos < 0)
1100+
if (offset_to_pack_pos(bitmap_git->pack, base_offset, &base_pos) < 0)
11041101
return;
11051102

11061103
/*

0 commit comments

Comments
 (0)