refs: drop `current_ref_iter` hack
In preceding commits we have refactored all callers of `peel_iterated_oid()` to instead use `reference_get_peeled_oid()`. This allows us to thus get rid of the former function. Getting rid of that function is nice, but even nicer is that this also allows us to get rid of the `current_ref_iter` hack. This global variable tracked the currently-active ref iterator so that we can use it to peel an object ID. Now that the peeled object ID is propagated via `struct reference` though we don't have to depend on this hack anymore, which makes for a more robust and easier-to-understand infrastructure. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
parent
feaaea4c12
commit
5a5c7359f7
10
refs.c
10
refs.c
|
|
@ -2324,16 +2324,6 @@ int refs_optimize(struct ref_store *refs, struct pack_refs_opts *opts)
|
|||
return refs->be->optimize(refs, opts);
|
||||
}
|
||||
|
||||
int peel_iterated_oid(struct repository *r, const struct object_id *base, struct object_id *peeled)
|
||||
{
|
||||
if (current_ref_iter &&
|
||||
(current_ref_iter->ref.oid == base ||
|
||||
oideq(current_ref_iter->ref.oid, base)))
|
||||
return ref_iterator_peel(current_ref_iter, peeled);
|
||||
|
||||
return peel_object(r, base, peeled) ? -1 : 0;
|
||||
}
|
||||
|
||||
int reference_get_peeled_oid(struct repository *repo,
|
||||
const struct reference *ref,
|
||||
struct object_id *peeled_oid)
|
||||
|
|
|
|||
|
|
@ -458,15 +458,11 @@ struct ref_iterator *prefix_ref_iterator_begin(struct ref_iterator *iter0,
|
|||
return ref_iterator;
|
||||
}
|
||||
|
||||
struct ref_iterator *current_ref_iter = NULL;
|
||||
|
||||
int do_for_each_ref_iterator(struct ref_iterator *iter,
|
||||
each_ref_fn fn, void *cb_data)
|
||||
{
|
||||
int retval = 0, ok;
|
||||
struct ref_iterator *old_ref_iter = current_ref_iter;
|
||||
|
||||
current_ref_iter = iter;
|
||||
while ((ok = ref_iterator_advance(iter)) == ITER_OK) {
|
||||
retval = fn(&iter->ref, cb_data);
|
||||
if (retval)
|
||||
|
|
@ -474,7 +470,6 @@ int do_for_each_ref_iterator(struct ref_iterator *iter,
|
|||
}
|
||||
|
||||
out:
|
||||
current_ref_iter = old_ref_iter;
|
||||
if (ok == ITER_ERROR)
|
||||
retval = -1;
|
||||
ref_iterator_free(iter);
|
||||
|
|
|
|||
|
|
@ -376,19 +376,6 @@ struct ref_iterator_vtable {
|
|||
ref_iterator_release_fn *release;
|
||||
};
|
||||
|
||||
/*
|
||||
* current_ref_iter is a performance hack: when iterating over
|
||||
* references using the for_each_ref*() functions, current_ref_iter is
|
||||
* set to the reference iterator before calling the callback function.
|
||||
* If the callback function calls peel_ref(), then peel_ref() first
|
||||
* checks whether the reference to be peeled is the one referred to by
|
||||
* the iterator (it usually is) and if so, asks the iterator for the
|
||||
* peeled version of the reference if it is available. This avoids a
|
||||
* refname lookup in a common case. current_ref_iter is set to NULL
|
||||
* when the iteration is over.
|
||||
*/
|
||||
extern struct ref_iterator *current_ref_iter;
|
||||
|
||||
struct ref_store;
|
||||
|
||||
/* refs backends */
|
||||
|
|
|
|||
Loading…
Reference in New Issue