From fc60d43cf3cf852c5b58d477b6ac895c62b9671c Mon Sep 17 00:00:00 2001 From: Martin Nilsson <mani@lysator.liu.se> Date: Tue, 1 Jun 2004 01:51:28 +0200 Subject: [PATCH] Save 170 bytes through constant tables. Rev: src/block_alloc.h:1.72 Rev: src/stuff.c:1.22 Rev: src/stuff.h:1.18 --- src/block_alloc.h | 6 +++--- src/stuff.c | 8 ++++---- src/stuff.h | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/block_alloc.h b/src/block_alloc.h index 10c8087abf..aca9d13728 100644 --- a/src/block_alloc.h +++ b/src/block_alloc.h @@ -2,7 +2,7 @@ || This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information. -|| $Id: block_alloc.h,v 1.71 2004/04/03 15:55:15 mast Exp $ +|| $Id: block_alloc.h,v 1.72 2004/05/31 23:51:28 nilsson Exp $ */ #undef PRE_INIT_BLOCK @@ -528,7 +528,7 @@ int PIKE_CONCAT(remove_,DATA)(void *ptr) \ \ void PIKE_CONCAT3(low_init_,DATA,_hash)(size_t size) \ { \ - extern INT32 hashprimes[32]; \ + extern const INT32 hashprimes[32]; \ extern int my_log2(size_t x); \ PIKE_CONCAT3(init_,DATA,_blocks)(); \ DO_IF_RUN_UNLOCKED(mt_lock(&PIKE_CONCAT(DATA,_mutex))); \ @@ -591,7 +591,7 @@ LOW_PTR_HASH_ALLOC(DATA,BSIZE) \ static void PIKE_CONCAT(DATA,_rehash)() \ { \ /* Time to re-hash */ \ - extern INT32 hashprimes[32]; \ + extern const INT32 hashprimes[32]; \ struct DATA **old_hash; \ struct DATA *p; \ PIKE_HASH_T hval; \ diff --git a/src/stuff.c b/src/stuff.c index 4663198bb5..20ce26052f 100644 --- a/src/stuff.c +++ b/src/stuff.c @@ -2,7 +2,7 @@ || This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information. -|| $Id: stuff.c,v 1.21 2002/10/11 01:39:38 nilsson Exp $ +|| $Id: stuff.c,v 1.22 2004/05/31 23:51:27 nilsson Exp $ */ #include "global.h" @@ -10,7 +10,7 @@ #include "stralloc.h" /* Not all of these are primes, but they should be adequate */ -PMOD_EXPORT INT32 hashprimes[32] = +PMOD_EXPORT const INT32 hashprimes[32] = { 31, /* ~ 2^0 = 1 */ 31, /* ~ 2^1 = 2 */ @@ -51,7 +51,7 @@ PMOD_EXPORT INT32 hashprimes[32] = PMOD_EXPORT int my_log2(size_t x) { - static signed char bit[256] = + static const signed char bit[256] = { -1, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, @@ -99,7 +99,7 @@ PMOD_EXPORT int count_bits(unsigned INT32 x) X+1,X+2,X+2,X+3,\ X+1,X+2,X+2,X+3,\ X+2,X+3,X+3,X+4 - static char bits[256] = + static const char bits[256] = { B(0), B(1), B(1), B(2), B(1), B(2), B(2), B(3), diff --git a/src/stuff.h b/src/stuff.h index 251d921ba8..608e3f4616 100644 --- a/src/stuff.h +++ b/src/stuff.h @@ -2,7 +2,7 @@ || This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information. -|| $Id: stuff.h,v 1.17 2004/05/19 00:13:13 nilsson Exp $ +|| $Id: stuff.h,v 1.18 2004/05/31 23:51:27 nilsson Exp $ */ #ifndef STUFF_H @@ -19,6 +19,6 @@ PMOD_EXPORT unsigned INT32 my_sqrt(unsigned INT32 n) ATTRIBUTE((const)); unsigned long find_good_hash_size(unsigned long x) ATTRIBUTE((const)); /* Prototypes end here */ -PMOD_EXPORT extern INT32 hashprimes[32]; +PMOD_EXPORT extern const INT32 hashprimes[32]; #endif -- GitLab