Skip to content

Commit 99430aa

Browse files
vdyegitster
authored andcommitted
Revert "unpack-trees: improve performance of next_cache_entry"
This reverts commit f2a454e (unpack-trees: improve performance of next_cache_entry, 2021-11-29). The "hint" value was originally needed to improve performance in 'git reset -- <pathspec>' caused by 'cache_bottom' lagging behind its correct value when using a sparse index. The 'cache_bottom' tracking has since been corrected, removing the need for an additional "pseudo-cache_bottom" tracking variable. Signed-off-by: Victoria Dye <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent bfc763d commit 99430aa

File tree

1 file changed

+6
-17
lines changed

1 file changed

+6
-17
lines changed

unpack-trees.c

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -644,24 +644,17 @@ static void mark_ce_used_same_name(struct cache_entry *ce,
644644
}
645645
}
646646

647-
static struct cache_entry *next_cache_entry(struct unpack_trees_options *o, int *hint)
647+
static struct cache_entry *next_cache_entry(struct unpack_trees_options *o)
648648
{
649649
const struct index_state *index = o->src_index;
650650
int pos = o->cache_bottom;
651651

652-
if (*hint > pos)
653-
pos = *hint;
654-
655652
while (pos < index->cache_nr) {
656653
struct cache_entry *ce = index->cache[pos];
657-
if (!(ce->ce_flags & CE_UNPACKED)) {
658-
*hint = pos + 1;
654+
if (!(ce->ce_flags & CE_UNPACKED))
659655
return ce;
660-
}
661656
pos++;
662657
}
663-
664-
*hint = pos;
665658
return NULL;
666659
}
667660

@@ -1409,13 +1402,12 @@ static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, str
14091402

14101403
/* Are we supposed to look at the index too? */
14111404
if (o->merge) {
1412-
int hint = -1;
14131405
while (1) {
14141406
int cmp;
14151407
struct cache_entry *ce;
14161408

14171409
if (o->diff_index_cached)
1418-
ce = next_cache_entry(o, &hint);
1410+
ce = next_cache_entry(o);
14191411
else
14201412
ce = find_cache_entry(info, p);
14211413

@@ -1777,7 +1769,7 @@ static int verify_absent(const struct cache_entry *,
17771769
int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options *o)
17781770
{
17791771
struct repository *repo = the_repository;
1780-
int i, hint, ret;
1772+
int i, ret;
17811773
static struct cache_entry *dfc;
17821774
struct pattern_list pl;
17831775
int free_pattern_list = 0;
@@ -1869,15 +1861,13 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
18691861
info.pathspec = o->pathspec;
18701862

18711863
if (o->prefix) {
1872-
hint = -1;
1873-
18741864
/*
18751865
* Unpack existing index entries that sort before the
18761866
* prefix the tree is spliced into. Note that o->merge
18771867
* is always true in this case.
18781868
*/
18791869
while (1) {
1880-
struct cache_entry *ce = next_cache_entry(o, &hint);
1870+
struct cache_entry *ce = next_cache_entry(o);
18811871
if (!ce)
18821872
break;
18831873
if (ce_in_traverse_path(ce, &info))
@@ -1898,9 +1888,8 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
18981888

18991889
/* Any left-over entries in the index? */
19001890
if (o->merge) {
1901-
hint = -1;
19021891
while (1) {
1903-
struct cache_entry *ce = next_cache_entry(o, &hint);
1892+
struct cache_entry *ce = next_cache_entry(o);
19041893
if (!ce)
19051894
break;
19061895
if (unpack_index_entry(ce, o) < 0)

0 commit comments

Comments
 (0)