Revert "unpack-trees: improve performance of next_cache_entry"
This reverts commit f2a454e0a5
(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 <vdye@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
bfc763df77
commit
99430aa12c
@ -644,24 +644,17 @@ static void mark_ce_used_same_name(struct cache_entry *ce,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct cache_entry *next_cache_entry(struct unpack_trees_options *o, int *hint)
|
static struct cache_entry *next_cache_entry(struct unpack_trees_options *o)
|
||||||
{
|
{
|
||||||
const struct index_state *index = o->src_index;
|
const struct index_state *index = o->src_index;
|
||||||
int pos = o->cache_bottom;
|
int pos = o->cache_bottom;
|
||||||
|
|
||||||
if (*hint > pos)
|
|
||||||
pos = *hint;
|
|
||||||
|
|
||||||
while (pos < index->cache_nr) {
|
while (pos < index->cache_nr) {
|
||||||
struct cache_entry *ce = index->cache[pos];
|
struct cache_entry *ce = index->cache[pos];
|
||||||
if (!(ce->ce_flags & CE_UNPACKED)) {
|
if (!(ce->ce_flags & CE_UNPACKED))
|
||||||
*hint = pos + 1;
|
|
||||||
return ce;
|
return ce;
|
||||||
}
|
|
||||||
pos++;
|
pos++;
|
||||||
}
|
}
|
||||||
|
|
||||||
*hint = pos;
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1409,13 +1402,12 @@ static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, str
|
|||||||
|
|
||||||
/* Are we supposed to look at the index too? */
|
/* Are we supposed to look at the index too? */
|
||||||
if (o->merge) {
|
if (o->merge) {
|
||||||
int hint = -1;
|
|
||||||
while (1) {
|
while (1) {
|
||||||
int cmp;
|
int cmp;
|
||||||
struct cache_entry *ce;
|
struct cache_entry *ce;
|
||||||
|
|
||||||
if (o->diff_index_cached)
|
if (o->diff_index_cached)
|
||||||
ce = next_cache_entry(o, &hint);
|
ce = next_cache_entry(o);
|
||||||
else
|
else
|
||||||
ce = find_cache_entry(info, p);
|
ce = find_cache_entry(info, p);
|
||||||
|
|
||||||
@ -1777,7 +1769,7 @@ static int verify_absent(const struct cache_entry *,
|
|||||||
int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options *o)
|
int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options *o)
|
||||||
{
|
{
|
||||||
struct repository *repo = the_repository;
|
struct repository *repo = the_repository;
|
||||||
int i, hint, ret;
|
int i, ret;
|
||||||
static struct cache_entry *dfc;
|
static struct cache_entry *dfc;
|
||||||
struct pattern_list pl;
|
struct pattern_list pl;
|
||||||
int free_pattern_list = 0;
|
int free_pattern_list = 0;
|
||||||
@ -1869,15 +1861,13 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
|
|||||||
info.pathspec = o->pathspec;
|
info.pathspec = o->pathspec;
|
||||||
|
|
||||||
if (o->prefix) {
|
if (o->prefix) {
|
||||||
hint = -1;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Unpack existing index entries that sort before the
|
* Unpack existing index entries that sort before the
|
||||||
* prefix the tree is spliced into. Note that o->merge
|
* prefix the tree is spliced into. Note that o->merge
|
||||||
* is always true in this case.
|
* is always true in this case.
|
||||||
*/
|
*/
|
||||||
while (1) {
|
while (1) {
|
||||||
struct cache_entry *ce = next_cache_entry(o, &hint);
|
struct cache_entry *ce = next_cache_entry(o);
|
||||||
if (!ce)
|
if (!ce)
|
||||||
break;
|
break;
|
||||||
if (ce_in_traverse_path(ce, &info))
|
if (ce_in_traverse_path(ce, &info))
|
||||||
@ -1898,9 +1888,8 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
|
|||||||
|
|
||||||
/* Any left-over entries in the index? */
|
/* Any left-over entries in the index? */
|
||||||
if (o->merge) {
|
if (o->merge) {
|
||||||
hint = -1;
|
|
||||||
while (1) {
|
while (1) {
|
||||||
struct cache_entry *ce = next_cache_entry(o, &hint);
|
struct cache_entry *ce = next_cache_entry(o);
|
||||||
if (!ce)
|
if (!ce)
|
||||||
break;
|
break;
|
||||||
if (unpack_index_entry(ce, o) < 0)
|
if (unpack_index_entry(ce, o) < 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user