[PATCH 10/17] Remove ineffective optimization
- From
mhagger@alum.mit.edu <mhagger@alum.mit.edu>
- Date
- Aug 23, 2012, 08:10 UTC
- Message-ID
- <1345709442-16046-11-git-send-email-mhagger@alum.mit.edu>
- In-Reply-To
- <1345709442-16046-1-git-send-email-mhagger@alum.mit.edu>
From: Michael Haggerty <mhagger@alum.mit.edu>
I cannot find a scenario in which this function is called any significant number of times, so simplify the code by always allocating an array for return_refs rather than trying to use a stack-allocated array for small lists.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> --- builtin/fetch-pack.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-)
diff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c index 0426cf4..9398059 100644 --- a/builtin/fetch-pack.c +++ b/builtin/fetch-pack.c @@ -527,17 +527,10 @@ static void filter_refs(struct ref **refs, int *nr_heads, char **heads) struct ref *newlist = NULL; struct ref **newtail = &newlist; struct ref *ref, *next; - struct ref *fastarray[32]; int match_pos; - if (*nr_heads && !args.fetch_all) { - if (ARRAY_SIZE(fastarray) < *nr_heads) - return_refs = xcalloc(*nr_heads, sizeof(struct ref *)); - else { - return_refs = fastarray; - memset(return_refs, 0, sizeof(struct ref *) * *nr_heads); - } - } + if (*nr_heads && !args.fetch_all) + return_refs = xcalloc(*nr_heads, sizeof(struct ref *)); else return_refs = NULL; @@ -584,8 +577,7 @@ static void filter_refs(struct ref **refs, int *nr_heads, char **heads) newtail = &ref->next; } } - if (return_refs != fastarray) - free(return_refs); + free(return_refs); } *refs = newlist; }
-- 1.7.11.3