Skip to content

Commit 162fc70

Browse files
pks-tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7d33bc6 commit 162fc70

File tree

3 files changed

+0
-28
lines changed

3 files changed

+0
-28
lines changed

refs.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2323,16 +2323,6 @@ int refs_optimize(struct ref_store *refs, struct pack_refs_opts *opts)
23232323
return refs->be->optimize(refs, opts);
23242324
}
23252325

2326-
int peel_iterated_oid(struct repository *r, const struct object_id *base, struct object_id *peeled)
2327-
{
2328-
if (current_ref_iter &&
2329-
(current_ref_iter->ref.oid == base ||
2330-
oideq(current_ref_iter->ref.oid, base)))
2331-
return ref_iterator_peel(current_ref_iter, peeled);
2332-
2333-
return peel_object(r, base, peeled) ? -1 : 0;
2334-
}
2335-
23362326
int reference_get_peeled_oid(struct repository *repo,
23372327
const struct reference *ref,
23382328
struct object_id *peeled_oid)

refs/iterator.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -458,23 +458,18 @@ struct ref_iterator *prefix_ref_iterator_begin(struct ref_iterator *iter0,
458458
return ref_iterator;
459459
}
460460

461-
struct ref_iterator *current_ref_iter = NULL;
462-
463461
int do_for_each_ref_iterator(struct ref_iterator *iter,
464462
each_ref_fn fn, void *cb_data)
465463
{
466464
int retval = 0, ok;
467-
struct ref_iterator *old_ref_iter = current_ref_iter;
468465

469-
current_ref_iter = iter;
470466
while ((ok = ref_iterator_advance(iter)) == ITER_OK) {
471467
retval = fn(&iter->ref, cb_data);
472468
if (retval)
473469
goto out;
474470
}
475471

476472
out:
477-
current_ref_iter = old_ref_iter;
478473
if (ok == ITER_ERROR)
479474
retval = -1;
480475
ref_iterator_free(iter);

refs/refs-internal.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -376,19 +376,6 @@ struct ref_iterator_vtable {
376376
ref_iterator_release_fn *release;
377377
};
378378

379-
/*
380-
* current_ref_iter is a performance hack: when iterating over
381-
* references using the for_each_ref*() functions, current_ref_iter is
382-
* set to the reference iterator before calling the callback function.
383-
* If the callback function calls peel_ref(), then peel_ref() first
384-
* checks whether the reference to be peeled is the one referred to by
385-
* the iterator (it usually is) and if so, asks the iterator for the
386-
* peeled version of the reference if it is available. This avoids a
387-
* refname lookup in a common case. current_ref_iter is set to NULL
388-
* when the iteration is over.
389-
*/
390-
extern struct ref_iterator *current_ref_iter;
391-
392379
struct ref_store;
393380

394381
/* refs backends */

0 commit comments

Comments
 (0)