2019-09-06 22:29:39

by Colin King

[permalink] [raw]
Subject: [PATCH] unicode: make array 'token' static const, makes object smaller

From: Colin Ian King <[email protected]>

Don't populate the array 'token' on the stack but instead make it
static const. Makes the object code smaller by 234 bytes.

Before:
text data bss dec hex filename
5371 272 0 5643 160b fs/unicode/utf8-core.o

After:
text data bss dec hex filename
5041 368 0 5409 1521 fs/unicode/utf8-core.o

(gcc version 9.2.1, amd64)

Signed-off-by: Colin Ian King <[email protected]>
---
fs/unicode/utf8-core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/unicode/utf8-core.c b/fs/unicode/utf8-core.c
index 71ca4d047d65..2a878b739115 100644
--- a/fs/unicode/utf8-core.c
+++ b/fs/unicode/utf8-core.c
@@ -154,7 +154,7 @@ static int utf8_parse_version(const char *version, unsigned int *maj,
{
substring_t args[3];
char version_string[12];
- const struct match_token token[] = {
+ static const struct match_token token[] = {
{1, "%d.%d.%d"},
{0, NULL}
};
--
2.20.1


2019-09-07 06:36:05

by Theodore Ts'o

[permalink] [raw]
Subject: Re: [PATCH] unicode: make array 'token' static const, makes object smaller

On Fri, Sep 06, 2019 at 02:58:07PM +0100, Colin King wrote:
> From: Colin Ian King <[email protected]>
>
> Don't populate the array 'token' on the stack but instead make it
> static const. Makes the object code smaller by 234 bytes.
>
> Before:
> text data bss dec hex filename
> 5371 272 0 5643 160b fs/unicode/utf8-core.o
>
> After:
> text data bss dec hex filename
> 5041 368 0 5409 1521 fs/unicode/utf8-core.o
>
> (gcc version 9.2.1, amd64)
>
> Signed-off-by: Colin Ian King <[email protected]>

Nice, thanks!

Reviewed-by: Theodore Ts'o <[email protected]>

- Ted

2019-09-10 18:26:53

by Gabriel Krisman Bertazi

[permalink] [raw]
Subject: Re: [PATCH] unicode: make array 'token' static const, makes object smaller

Colin King <[email protected]> writes:

> From: Colin Ian King <[email protected]>
>
> Don't populate the array 'token' on the stack but instead make it
> static const. Makes the object code smaller by 234 bytes.
>
> Before:
> text data bss dec hex filename
> 5371 272 0 5643 160b fs/unicode/utf8-core.o
>
> After:
> text data bss dec hex filename
> 5041 368 0 5409 1521 fs/unicode/utf8-core.o
>
> (gcc version 9.2.1, amd64)
>
> Signed-off-by: Colin Ian King <[email protected]>

Thanks, I will get this queued up.

--
Gabriel Krisman Bertazi