Skip to contentSkip to conversation

unicode: make array 'token' static const, makes object smaller

PATCH In review Colin King 3 participants 3 messages Sep 6, 2019 – Sep 9, 2019

Subsystems (3)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 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)

---
 fs/unicode/utf8-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/unicode/utf8-core.c +1 -1
index 71ca4d047d65..2a878b739115 100644
@@ -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}
 	};
Signature · 1 line
2.20.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Colin King

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

Quoted 7 lines

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

(gcc version 9.2.1, amd64)

Nice, thanks!

- Ted

#2 lore raw
In reply to Colin King
Quoted 9 lines · Colin King

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

Quoted 7 lines

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

(gcc version 9.2.1, amd64)

Thanks, I will get this queued up.

Signature · 1 line
Gabriel Krisman Bertazi