diff mbox series

[7/9] stash: declare ref_stash as an array

Message ID b5f22de3fc320d23ba2c5342776b56770266ca5f.1612258145.git.liu.denton@gmail.com (mailing list archive)
State Superseded
Headers show
Series stash show: learn --include-untracked and --only-untracked | expand

Commit Message

Denton Liu Feb. 2, 2021, 9:33 a.m. UTC
Save sizeof(const char *) bytes by declaring ref_stash as an array
instead of having a redundant pointer to an array.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
---
 builtin/stash.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Junio C Hamano Feb. 2, 2021, 9:46 p.m. UTC | #1
Denton Liu <liu.denton@gmail.com> writes:

> Save sizeof(const char *) bytes by declaring ref_stash as an array
> instead of having a redundant pointer to an array.

One important prerequisite for this rewrite to work is that nobody
in the code repoints ref_stash pointer to point at a different
string, which has been the case for the past number of years and
will continue to be so.

Looks good.

> Signed-off-by: Denton Liu <liu.denton@gmail.com>
> ---
>  builtin/stash.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/builtin/stash.c b/builtin/stash.c
> index 9bc85f91cd..6f2b58f6ab 100644
> --- a/builtin/stash.c
> +++ b/builtin/stash.c
> @@ -87,7 +87,7 @@ static const char * const git_stash_save_usage[] = {
>  	NULL
>  };
>  
> -static const char *ref_stash = "refs/stash";
> +static const char ref_stash[] = "refs/stash";
>  static struct strbuf stash_index_path = STRBUF_INIT;
>  
>  /*
diff mbox series

Patch

diff --git a/builtin/stash.c b/builtin/stash.c
index 9bc85f91cd..6f2b58f6ab 100644
--- a/builtin/stash.c
+++ b/builtin/stash.c
@@ -87,7 +87,7 @@  static const char * const git_stash_save_usage[] = {
 	NULL
 };
 
-static const char *ref_stash = "refs/stash";
+static const char ref_stash[] = "refs/stash";
 static struct strbuf stash_index_path = STRBUF_INIT;
 
 /*