public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] lib/lz4: make arrays static const, reduces object code size
@ 2017-09-21 22:19 Colin King
  2017-09-21 23:09 ` Christophe JAILLET
  0 siblings, 1 reply; 11+ messages in thread
From: Colin King @ 2017-09-21 22:19 UTC (permalink / raw)
  To: Sven Schmidt, Andrew Morton, Arnd Bergmann; +Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

Don't populate the read-only arrays dec32table and dec64table on the
stack, instead make them both static const.  Makes the object code
smaller by over 10K bytes:

Before:
   text	   data	    bss	    dec	    hex	filename
  31500	      0	      0	  31500	   7b0c	lib/lz4/lz4_decompress.o

After:
   text	   data	    bss	    dec	    hex	filename
  20237	    176	      0	  20413	   4fbd	lib/lz4/lz4_decompress.o

(gcc version 7.2.0 x86_64)

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 lib/lz4/lz4_decompress.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/lz4/lz4_decompress.c b/lib/lz4/lz4_decompress.c
index bd3574312b82..141734d255e4 100644
--- a/lib/lz4/lz4_decompress.c
+++ b/lib/lz4/lz4_decompress.c
@@ -85,8 +85,8 @@ static FORCE_INLINE int LZ4_decompress_generic(
 	const BYTE * const lowLimit = lowPrefix - dictSize;
 
 	const BYTE * const dictEnd = (const BYTE *)dictStart + dictSize;
-	const unsigned int dec32table[] = { 0, 1, 2, 1, 4, 4, 4, 4 };
-	const int dec64table[] = { 0, 0, 0, -1, 0, 1, 2, 3 };
+	static const unsigned int dec32table[] = { 0, 1, 2, 1, 4, 4, 4, 4 };
+	static const int dec64table[] = { 0, 0, 0, -1, 0, 1, 2, 3 };
 
 	const int safeDecode = (endOnInput = endOnInputSize);
 	const int checkOffset = ((safeDecode) && (dictSize < (int)(64 * KB)));
-- 
2.14.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2017-09-23  1:33 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-21 22:19 [PATCH] lib/lz4: make arrays static const, reduces object code size Colin King
2017-09-21 23:09 ` Christophe JAILLET
2017-09-21 23:11   ` Colin Ian King
2017-09-22  7:48     ` Arnd Bergmann
2017-09-22 17:21       ` Joe Perches
2017-09-22 19:17         ` Arnd Bergmann
2017-09-22 19:38           ` Arnd Bergmann
2017-09-22 21:39           ` Arnd Bergmann
2017-09-22 21:43             ` Colin Ian King
2017-09-23  1:33             ` Joe Perches
2017-09-23  1:33           ` Joe Perches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox