[PATCH 10/17] Remove ineffective optimization
From: <hidden>
Date: 2016-06-15 22:54:33
Subsystem:
the rest · Maintainer:
Linus Torvalds
From: Michael Haggerty <redacted> 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 <redacted> --- 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