[PATCH 05/10] name-rev: don't _peek() in create_or_update_name()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxx>
---
 builtin/name-rev.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/builtin/name-rev.c b/builtin/name-rev.c
index 3e22a0503e..41aed436ca 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;
--
2.25.0




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux