Skip to content

Commit 199c86b

Browse files
peffgitster
authored andcommitted
pack-bitmap: drop "loaded" flag
In the early days of the bitmap code, there was a single static bitmap_index struct that was used behind the scenes, and any bitmap-related functions could lazily check bitmap_git.loaded to see if they needed to read the on-disk data. But since 3ae5fa0 (pack-bitmap: remove bitmap_git global variable, 2018-06-07), the caller is responsible for the lifetime of the bitmap_index struct, and we return it from prepare_bitmap_git() and prepare_bitmap_walk(), both of which load the on-disk data (or return NULL). So outside of these functions, it's not possible to have a bitmap_index for which the loaded flag is not true. Nor is it possible to accidentally pass an already-loaded bitmap_index to the loading function (which is static-local to the file). We can drop this unnecessary and confusing flag. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 715d0c5 commit 199c86b

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

pack-bitmap.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,6 @@ struct bitmap_index {
9191

9292
/* Version of the bitmap index */
9393
unsigned int version;
94-
95-
unsigned loaded : 1;
9694
};
9795

9896
static struct ewah_bitmap *lookup_stored_bitmap(struct stored_bitmap *st)
@@ -306,7 +304,7 @@ static int open_pack_bitmap_1(struct bitmap_index *bitmap_git, struct packed_git
306304

307305
static int load_pack_bitmap(struct bitmap_index *bitmap_git)
308306
{
309-
assert(bitmap_git->map && !bitmap_git->loaded);
307+
assert(bitmap_git->map);
310308

311309
bitmap_git->bitmaps = kh_init_sha1();
312310
bitmap_git->ext_index.positions = kh_init_sha1_pos();
@@ -321,7 +319,6 @@ static int load_pack_bitmap(struct bitmap_index *bitmap_git)
321319
if (load_bitmap_entries_v1(bitmap_git) < 0)
322320
goto failed;
323321

324-
bitmap_git->loaded = 1;
325322
return 0;
326323

327324
failed:
@@ -336,7 +333,7 @@ static int open_pack_bitmap(struct bitmap_index *bitmap_git)
336333
struct packed_git *p;
337334
int ret = -1;
338335

339-
assert(!bitmap_git->map && !bitmap_git->loaded);
336+
assert(!bitmap_git->map);
340337

341338
for (p = get_packed_git(the_repository); p; p = p->next) {
342339
if (open_pack_bitmap_1(bitmap_git, p) == 0)
@@ -738,7 +735,7 @@ struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs)
738735
* from disk. this is the point of no return; after this the rev_list
739736
* becomes invalidated and we must perform the revwalk through bitmaps
740737
*/
741-
if (!bitmap_git->loaded && load_pack_bitmap(bitmap_git) < 0)
738+
if (load_pack_bitmap(bitmap_git) < 0)
742739
goto cleanup;
743740

744741
object_array_clear(&revs->pending);

0 commit comments

Comments
 (0)