summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: dccd0c2)
raw | patch | inline | side by side (parent: dccd0c2)
author | Shawn O. Pearce <spearce@spearce.org> | |
Sat, 13 Jan 2007 22:28:16 +0000 (17:28 -0500) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Mon, 15 Jan 2007 05:17:27 +0000 (21:17 -0800) |
If a project has a very large number of tags then git-describe
will spend a good part of its time looping over the tags testing
them one at a time to determine if it matches a given commit.
For 10 tags this is not a big deal, but for hundreds of tags the
time could become considerable if we don't find an exact match for
the input commit and we need to walk back along the history chain.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
will spend a good part of its time looping over the tags testing
them one at a time to determine if it matches a given commit.
For 10 tags this is not a big deal, but for hundreds of tags the
time could become considerable if we don't find an exact match for
the input commit and we need to walk back along the history chain.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
builtin-describe.c | patch | blob | history |
diff --git a/builtin-describe.c b/builtin-describe.c
index ad672aa8ee7b2f791881d8aa7ec9084a68ac6c8c..582ef023f7c8d00576c403ec80b7e541d3edf494 100644 (file)
--- a/builtin-describe.c
+++ b/builtin-describe.c
static int all; /* Default to annotated tags only */
static int tags; /* But allow any tags if --tags is specified */
-
static int abbrev = DEFAULT_ABBREV;
-static int names, allocs;
+static unsigned int names[256], allocs[256];
static struct commit_name {
struct commit *commit;
int prio; /* annotated tag = 2, tag = 1, head = 0 */
char path[FLEX_ARRAY]; /* more */
-} **name_array = NULL;
+} **name_array[256];
static struct commit_name *match(struct commit *cmit)
{
- int i = names;
- struct commit_name **p = name_array;
+ unsigned char m = cmit->object.sha1[0];
+ unsigned int i = names[m];
+ struct commit_name **p = name_array[m];
while (i-- > 0) {
struct commit_name *n = *p++;
int idx;
int len = strlen(path)+1;
struct commit_name *name = xmalloc(sizeof(struct commit_name) + len);
+ unsigned char m = commit->object.sha1[0];
name->commit = commit;
name->prio = prio;
memcpy(name->path, path, len);
- idx = names;
- if (idx >= allocs) {
- allocs = (idx + 50) * 3 / 2;
- name_array = xrealloc(name_array, allocs*sizeof(*name_array));
+ idx = names[m];
+ if (idx >= allocs[m]) {
+ allocs[m] = (idx + 50) * 3 / 2;
+ name_array[m] = xrealloc(name_array[m],
+ allocs[m] * sizeof(*name_array));
}
- name_array[idx] = name;
- names = ++idx;
+ name_array[m][idx] = name;
+ names[m] = ++idx;
}
static int get_name(const char *path, const unsigned char *sha1, int flag, void *cb_data)
die("%s is not a valid '%s' object", arg, commit_type);
if (!initialized) {
+ unsigned int m;
initialized = 1;
for_each_ref(get_name, NULL);
- qsort(name_array, names, sizeof(*name_array), compare_names);
+ for (m = 0; m < ARRAY_SIZE(name_array); m++)
+ qsort(name_array[m], names[m],
+ sizeof(*name_array[m]), compare_names);
}
n = match(cmit);