mirror of
https://github.com/git/git.git
synced 2026-01-11 21:33:13 +09:00
midx-write.c: factor fanout layering from compute_sorted_entries()
When computing the set of objects to appear in a MIDX, we use compute_sorted_entries(), which handles objects from various existing sources one fanout layer at a time. The process for computing this set is slightly different during MIDX compaction, so factor out the existing functionality into its own routine to prevent `compute_sorted_entries()` from becoming too difficult to read. Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
cad0632e13
commit
477f9c1b21
42
midx-write.c
42
midx-write.c
@ -323,6 +323,30 @@ static void midx_fanout_add_pack_fanout(struct midx_fanout *fanout,
|
||||
}
|
||||
}
|
||||
|
||||
static void midx_fanout_add(struct midx_fanout *fanout,
|
||||
struct write_midx_context *ctx,
|
||||
uint32_t start_pack,
|
||||
uint32_t cur_fanout)
|
||||
{
|
||||
uint32_t cur_pack;
|
||||
|
||||
if (ctx->m && !ctx->incremental)
|
||||
midx_fanout_add_midx_fanout(fanout, ctx->m, cur_fanout,
|
||||
ctx->preferred_pack_idx);
|
||||
|
||||
for (cur_pack = start_pack; cur_pack < ctx->nr; cur_pack++) {
|
||||
int preferred = cur_pack == ctx->preferred_pack_idx;
|
||||
midx_fanout_add_pack_fanout(fanout, ctx->info, cur_pack,
|
||||
preferred, cur_fanout);
|
||||
}
|
||||
|
||||
if (ctx->preferred_pack_idx != NO_PREFERRED_PACK &&
|
||||
ctx->preferred_pack_idx < start_pack)
|
||||
midx_fanout_add_pack_fanout(fanout, ctx->info,
|
||||
ctx->preferred_pack_idx, 1,
|
||||
cur_fanout);
|
||||
}
|
||||
|
||||
/*
|
||||
* It is possible to artificially get into a state where there are many
|
||||
* duplicate copies of objects. That can create high memory pressure if
|
||||
@ -359,23 +383,7 @@ static void compute_sorted_entries(struct write_midx_context *ctx,
|
||||
for (cur_fanout = 0; cur_fanout < 256; cur_fanout++) {
|
||||
fanout.nr = 0;
|
||||
|
||||
if (ctx->m && !ctx->incremental)
|
||||
midx_fanout_add_midx_fanout(&fanout, ctx->m, cur_fanout,
|
||||
ctx->preferred_pack_idx);
|
||||
|
||||
for (cur_pack = start_pack; cur_pack < ctx->nr; cur_pack++) {
|
||||
int preferred = cur_pack == ctx->preferred_pack_idx;
|
||||
midx_fanout_add_pack_fanout(&fanout,
|
||||
ctx->info, cur_pack,
|
||||
preferred, cur_fanout);
|
||||
}
|
||||
|
||||
if (ctx->preferred_pack_idx != NO_PREFERRED_PACK &&
|
||||
ctx->preferred_pack_idx < start_pack)
|
||||
midx_fanout_add_pack_fanout(&fanout, ctx->info,
|
||||
ctx->preferred_pack_idx, 1,
|
||||
cur_fanout);
|
||||
|
||||
midx_fanout_add(&fanout, ctx, start_pack, cur_fanout);
|
||||
midx_fanout_sort(&fanout);
|
||||
|
||||
/*
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user