From c653917259296bc9c63b42e19077a1ea0c312cd2 Mon Sep 17 00:00:00 2001 From: Per Hedbor <ph@opera.com> Date: Mon, 2 May 2011 03:50:19 +0200 Subject: [PATCH] Since array.c is the only place the is_more_than_one_bit function is used, and it is, unlike many of our macros, suitable for inlining, inline it. --- src/array.c | 6 ++++++ src/stuff.c | 12 +++++------- src/stuff.h | 5 ++--- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/array.c b/src/array.c index 3f58f961d5..f3d61c5937 100644 --- a/src/array.c +++ b/src/array.c @@ -2098,6 +2098,12 @@ int array_is_constant(struct array *a, p); } +/* Return true for integers with more than one bit set */ +static inline int is_more_than_one_bit(unsigned INT32 x) +{ + return !!(x & (x-1)); +} + node *make_node_from_array(struct array *a) { struct svalue s; diff --git a/src/stuff.c b/src/stuff.c index 0458c57b50..e336d28f75 100644 --- a/src/stuff.c +++ b/src/stuff.c @@ -29,7 +29,7 @@ PMOD_EXPORT const char Pike_is8bitalnum_vector[] = "1111111011111111"; /* Not all of these are primes, but they should be adequate */ -PMOD_EXPORT const INT32 hashprimes[32] = +const INT32 hashprimes[32] = { 31, /* ~ 2^0 = 1 */ 31, /* ~ 2^1 = 2 */ @@ -111,6 +111,7 @@ PMOD_EXPORT int my_log2(size_t x) } +#if 0 /* Return the number of bits in a 32-bit integer */ PMOD_EXPORT int count_bits(unsigned INT32 x) { @@ -131,12 +132,7 @@ PMOD_EXPORT int count_bits(unsigned INT32 x) bits[(x>>16) & 255] + bits[(x>>24) & 255]); } - -/* Return true for integers with more than one bit set */ -PMOD_EXPORT int is_more_than_one_bit(unsigned INT32 x) -{ - return !!(x & (x-1)); -} +#endif PMOD_EXPORT double my_strtod(char *nptr, char **endptr) { @@ -165,6 +161,7 @@ PMOD_EXPORT unsigned INT32 my_sqrt(unsigned INT32 n) return x; } +#if 0 /* This routine basically finds a prime number * which is larger than 'x' */ @@ -430,6 +427,7 @@ unsigned long find_good_hash_size(unsigned long num) return primes[y]; } +#endif /* * This rounds an integer up to the next power of two. For x a power diff --git a/src/stuff.h b/src/stuff.h index a39f04b934..d6af0fa110 100644 --- a/src/stuff.h +++ b/src/stuff.h @@ -13,13 +13,12 @@ /* Prototypes begin here */ PMOD_EXPORT int my_log2(size_t x) ATTRIBUTE((const)); PMOD_EXPORT int count_bits(unsigned INT32 x) ATTRIBUTE((const)); -PMOD_EXPORT int is_more_than_one_bit(unsigned INT32 x) ATTRIBUTE((const)); PMOD_EXPORT double my_strtod(char *nptr, char **endptr); PMOD_EXPORT unsigned INT32 my_sqrt(unsigned INT32 n) ATTRIBUTE((const)); -unsigned long find_good_hash_size(unsigned long x) ATTRIBUTE((const)); +/* unsigned long find_good_hash_size(unsigned long x) ATTRIBUTE((const)); */ unsigned INT32 find_next_power(unsigned INT32 x) ATTRIBUTE((const)); /* Prototypes end here */ -PMOD_EXPORT extern const INT32 hashprimes[32]; +extern const INT32 hashprimes[32]; #endif -- GitLab