unpack-trees: refactor prefetching code
Refactor the prefetching code in unpack-trees.c into its own function, because it will be used elsewhere in a subsequent commit. Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
eb27b338a3
commit
b2896d2739
23
read-cache.c
23
read-cache.c
@ -27,6 +27,7 @@
|
||||
#include "progress.h"
|
||||
#include "sparse-index.h"
|
||||
#include "csum-file.h"
|
||||
#include "promisor-remote.h"
|
||||
|
||||
/* Mask for the name length in ce_flags in the on-disk index */
|
||||
|
||||
@ -3657,3 +3658,25 @@ static void write_ieot_extension(struct strbuf *sb, struct index_entry_offset_ta
|
||||
strbuf_add(sb, &buffer, sizeof(uint32_t));
|
||||
}
|
||||
}
|
||||
|
||||
void prefetch_cache_entries(const struct index_state *istate,
|
||||
must_prefetch_predicate must_prefetch)
|
||||
{
|
||||
int i;
|
||||
struct oid_array to_fetch = OID_ARRAY_INIT;
|
||||
|
||||
for (i = 0; i < istate->cache_nr; i++) {
|
||||
struct cache_entry *ce = istate->cache[i];
|
||||
|
||||
if (S_ISGITLINK(ce->ce_mode) || !must_prefetch(ce))
|
||||
continue;
|
||||
if (!oid_object_info_extended(the_repository, &ce->oid,
|
||||
NULL,
|
||||
OBJECT_INFO_FOR_PREFETCH))
|
||||
continue;
|
||||
oid_array_append(&to_fetch, &ce->oid);
|
||||
}
|
||||
promisor_remote_get_direct(the_repository,
|
||||
to_fetch.oid, to_fetch.nr);
|
||||
oid_array_clear(&to_fetch);
|
||||
}
|
||||
|
Reference in New Issue
Block a user