refs: document how current_ref is used
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty committed
Apr 22, 2013 at 21:52 UTC
7d76fdc8299639096ace153aef0f0b96dcc5b308
1 file changed
+9
refs.c
+9
@@ -529,6 +529,15 @@ static void sort_ref_dir(struct ref_dir *dir)
529
/* Include broken references in a do_for_each_ref*() iteration: */
530
#define DO_FOR_EACH_INCLUDE_BROKEN 0x01
531
532
+/*
533
+ * current_ref is a performance hack: when iterating over references
534
+ * using the for_each_ref*() functions, current_ref is set to the
535
+ * current reference's entry before calling the callback function. If
536
+ * the callback function calls peel_ref(), then peel_ref() first
537
+ * checks whether the reference to be peeled is the current reference
538
+ * (it usually is) and if so, returns that reference's peeled version
539
+ * if it is available. This avoids a refname lookup in a common case.
540
+ */
541
static struct ref_entry *current_ref;
542
543
/*