summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2020-02-04 21:20:42 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-02-05 18:24:15 (GMT)
commitd689d6d82fae2f4f948bf1c232cb1fe158e3f319 (patch)
treef2187f4f2708db210664dc74ac9fb79c3b4bcfa4 /builtin
parent15a4205d967111856279993b8aca24d4ffae787b (diff)
downloadgit-d689d6d82fae2f4f948bf1c232cb1fe158e3f319.zip
git-d689d6d82fae2f4f948bf1c232cb1fe158e3f319.tar.gz
git-d689d6d82fae2f4f948bf1c232cb1fe158e3f319.tar.bz2
name-rev: don't _peek() in create_or_update_name()
Look up the commit slab slot for the commit once using commit_rev_name_at() and populate it in case it is empty, instead of checking for emptiness in a separate step using commit_rev_name_peek() via get_commit_rev_name(). Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/name-rev.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/builtin/name-rev.c b/builtin/name-rev.c
index 3e22a05..41aed43 100644
--- a/builtin/name-rev.c
+++ b/builtin/name-rev.c
@@ -39,11 +39,6 @@ static struct rev_name *get_commit_rev_name(const struct commit *commit)
return slot ? *slot : NULL;
}
-static void set_commit_rev_name(struct commit *commit, struct rev_name *name)
-{
- *commit_rev_name_at(&rev_names, commit) = name;
-}
-
static int is_better_name(struct rev_name *name,
timestamp_t taggerdate,
int distance,
@@ -86,15 +81,14 @@ static struct rev_name *create_or_update_name(struct commit *commit,
int generation, int distance,
int from_tag)
{
- struct rev_name *name = get_commit_rev_name(commit);
+ struct rev_name **slot = commit_rev_name_at(&rev_names, commit);
+ struct rev_name *name = *slot;
if (name && !is_better_name(name, taggerdate, distance, from_tag))
return NULL;
- if (name == NULL) {
- name = xmalloc(sizeof(*name));
- set_commit_rev_name(commit, name);
- }
+ if (!name)
+ name = *slot = xmalloc(sizeof(*name));
name->tip_name = tip_name;
name->taggerdate = taggerdate;