From: Michael Haggerty Date: Mon, 22 Apr 2013 19:52:12 GMT Subject: [PATCH v2 04/33] refs: document how current_ref is used Message-ID: <1366660361-21831-5-git-send-email-mhagger@alum.mit.edu> In-Reply-To: <1366660361-21831-1-git-send-email-mhagger@alum.mit.edu> Signed-off-by: Michael Haggerty --- refs.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/refs.c b/refs.c index 44cc2fc..efad658 100644 --- a/refs.c +++ b/refs.c @@ -528,6 +528,15 @@ static void sort_ref_dir(struct ref_dir *dir) /* Include broken references in a do_for_each_ref*() iteration: */ #define DO_FOR_EACH_INCLUDE_BROKEN 0x01 +/* + * current_ref is a performance hack: when iterating over references + * using the for_each_ref*() functions, current_ref is set to the + * current reference's entry 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 current reference + * (it usually is) and if so, returns that reference's peeled version + * if it is available. This avoids a refname lookup in a common case. + */ static struct ref_entry *current_ref; /* -- 1.8.2.1