[04/15] name-rev: avoid unnecessary cast in name_ref()
diff mbox series

Message ID 20190919214712.7348-5-szeder.dev@gmail.com
State New
Headers show
Series
  • name-rev: eliminate recursion
Related show

Commit Message

SZEDER Gábor Sept. 19, 2019, 9:46 p.m. UTC
Casting a 'struct object' to 'struct commit' is unnecessary there,
because it's already available in the local 'commit' variable.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
---
 builtin/name-rev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

René Scharfe Sept. 20, 2019, 4:37 p.m. UTC | #1
Am 19.09.19 um 23:46 schrieb SZEDER Gábor:
> Casting a 'struct object' to 'struct commit' is unnecessary there,
> because it's already available in the local 'commit' variable.

That's true, but you can't see that only by reading your email.

>
> Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
> ---
>  builtin/name-rev.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/builtin/name-rev.c b/builtin/name-rev.c
> index d345456656..e406ff8e17 100644
> --- a/builtin/name-rev.c
> +++ b/builtin/name-rev.c
> @@ -268,7 +268,7 @@ static int name_ref(const char *path, const struct object_id *oid, int flags, vo

Here's the pertinent context line; --function-context would have been too
much, I think, but -U4 would have shown it:

		struct commit *commit = (struct commit *)o;
>  		int from_tag = starts_with(path, "refs/tags/");
>
>  		if (taggerdate == TIME_MAX)
> -			taggerdate = ((struct commit *)o)->date;
> +			taggerdate = commit->date;
>  		path = name_ref_abbrev(path, can_abbreviate_output);
>  		name_rev(commit, xstrdup(path), taggerdate, 0, 0,
>  			 from_tag, deref);
>

Patch
diff mbox series

diff --git a/builtin/name-rev.c b/builtin/name-rev.c
index d345456656..e406ff8e17 100644
--- a/builtin/name-rev.c
+++ b/builtin/name-rev.c
@@ -268,7 +268,7 @@  static int name_ref(const char *path, const struct object_id *oid, int flags, vo
 		int from_tag = starts_with(path, "refs/tags/");
 
 		if (taggerdate == TIME_MAX)
-			taggerdate = ((struct commit *)o)->date;
+			taggerdate = commit->date;
 		path = name_ref_abbrev(path, can_abbreviate_output);
 		name_rev(commit, xstrdup(path), taggerdate, 0, 0,
 			 from_tag, deref);