diff options
author | Yves Orton <demerphq@gmail.com> | 2014-12-25 03:29:57 +0100 |
---|---|---|
committer | Yves Orton <demerphq@gmail.com> | 2014-12-25 03:33:36 +0100 |
commit | 3efdcc9cc52ff5b9575a7be650bd473a7a56f550 (patch) | |
tree | 806ed78744d6c65506d13ecdd09267b72f0687c5 /hv_func.h | |
parent | 8fbcb657f30d2c6ce842ca969787dcb532341df5 (diff) | |
download | perl-3efdcc9cc52ff5b9575a7be650bd473a7a56f550.tar.gz |
Revert "dont compile unused static hash functions"
This reverts commit 09c759bcfa4c2880c571df4da20458b2f781debf.
The reverted patch causes us to not compile functions that we might
not use. In theory this is a good thing. But any competent compiler
is going to exclude them anyway if they aren't used, and we might
miss useful warning messages, or whatnot. See b404539126a for an
example of a patch that would not have happened, or would only
have been partially done had this patch been applied.
Also the reverted patch claimed that "It is not safe to have multiple
hash funcs in 1 build due to conflicts on the size of
PERL_HASH_SEED_BYTES." which is incorrect. The functions do not
reference PERL_HASH_SEED_BYTES directly, and are usable by anyone
who knows what size of seed they need.
Additionally I have on my long-term todo list the following:
* Allow Perl to randomly select the hash function at startup
* Allow Perl to use the hash function determined by the ENV at startup.
This patch would have to be reverted to complete either of those tasks.
To recap, I am reverting this patch because it adds no real value,
makes our hash functions susceptible to bit-rot, and because it blocks
interesting future changes that I plan to work on in the future.
Diffstat (limited to 'hv_func.h')
-rw-r--r-- | hv_func.h | 20 |
1 files changed, 4 insertions, 16 deletions
@@ -179,7 +179,6 @@ * It is 64 bit only. */ -#if defined(PERL_HASH_FUNC_SIPHASH) #ifdef HAS_QUAD #define U8TO64_LE(p) \ @@ -258,7 +257,6 @@ S_perl_hash_siphash_2_4(const unsigned char * const seed, const unsigned char *i return (U32)(b & U32_MAX); } #endif /* defined(HAS_QUAD) */ -#endif /* defined(PERL_HASH_FUNC_SIPHASH) */ /* FYI: This is the "Super-Fast" algorithm mentioned by Bob Jenkins in * (http://burtleburtle.net/bob/hash/doobs.html) @@ -268,7 +266,7 @@ S_perl_hash_siphash_2_4(const unsigned char * const seed, const unsigned char *i * http://www.azillionmonkeys.com/qed/weblicense.html */ -#if defined(PERL_HASH_FUNC_SUPERFAST) + PERL_STATIC_INLINE U32 S_perl_hash_superfast(const unsigned char * const seed, const unsigned char *str, STRLEN len) { U32 hash = *((U32*)seed) + (U32)len; @@ -307,7 +305,7 @@ S_perl_hash_superfast(const unsigned char * const seed, const unsigned char *str hash ^= hash << 25; return (hash + (hash >> 6)); } -#endif /* defined(PERL_HASH_FUNC_SUPERFAST) */ + /*----------------------------------------------------------------------------- * MurmurHash3 was written by Austin Appleby, and is placed in the public @@ -334,7 +332,7 @@ S_perl_hash_superfast(const unsigned char * const seed, const unsigned char *str * on big endian machines, or a byte-by-byte read if the endianess is unknown. */ -#if defined(PERL_HASH_FUNC_MURMUR3) + /*----------------------------------------------------------------------------- * Core murmurhash algorithm macros */ @@ -464,9 +462,8 @@ S_perl_hash_murmur3(const unsigned char * const seed, const unsigned char *ptr, h1 ^= h1 >> 16; return h1; } -#endif /* defined(PERL_HASH_FUNC_MURMUR3) */ -#if defined(PERL_HASH_FUNC_DJB2) + PERL_STATIC_INLINE U32 S_perl_hash_djb2(const unsigned char * const seed, const unsigned char *str, const STRLEN len) { const unsigned char * const end = (const unsigned char *)str + len; @@ -476,9 +473,7 @@ S_perl_hash_djb2(const unsigned char * const seed, const unsigned char *str, con } return hash; } -#endif /* defined(PERL_HASH_FUNC_DJB2) */ -#if defined(PERL_HASH_FUNC_SDBM) PERL_STATIC_INLINE U32 S_perl_hash_sdbm(const unsigned char * const seed, const unsigned char *str, const STRLEN len) { const unsigned char * const end = (const unsigned char *)str + len; @@ -488,7 +483,6 @@ S_perl_hash_sdbm(const unsigned char * const seed, const unsigned char *str, con } return hash; } -#endif /* defined(PERL_HASH_FUNC_SDBM) */ /* - ONE_AT_A_TIME_HARD is the 5.17+ recommend ONE_AT_A_TIME algorithm * - ONE_AT_A_TIME_OLD is the unmodified 5.16 and older algorithm @@ -506,7 +500,6 @@ S_perl_hash_sdbm(const unsigned char * const seed, const unsigned char *str, con * (http://burtleburtle.net/bob/hash/doobs.html) * With seed/len tweak. * */ -#if defined(PERL_HASH_FUNC_ONE_AT_A_TIME) PERL_STATIC_INLINE U32 S_perl_hash_one_at_a_time(const unsigned char * const seed, const unsigned char *str, const STRLEN len) { const unsigned char * const end = (const unsigned char *)str + len; @@ -520,10 +513,8 @@ S_perl_hash_one_at_a_time(const unsigned char * const seed, const unsigned char hash ^= (hash >> 11); return (hash + (hash << 15)); } -#endif /* defined(PERL_HASH_FUNC_ONE_AT_A_TIME) */ /* Derived from "One-at-a-Time" algorithm by Bob Jenkins */ -#if defined(PERL_HASH_FUNC_ONE_AT_A_TIME_HARD) PERL_STATIC_INLINE U32 S_perl_hash_one_at_a_time_hard(const unsigned char * const seed, const unsigned char *str, const STRLEN len) { const unsigned char * const end = (const unsigned char *)str + len; @@ -558,9 +549,7 @@ S_perl_hash_one_at_a_time_hard(const unsigned char * const seed, const unsigned hash ^= (hash >> 11); return (hash + (hash << 15)); } -#endif /* defined(PERL_HASH_FUNC_ONE_AT_A_TIME_HARD) */ -#if defined(PERL_HASH_FUNC_ONE_AT_A_TIME_OLD) PERL_STATIC_INLINE U32 S_perl_hash_old_one_at_a_time(const unsigned char * const seed, const unsigned char *str, const STRLEN len) { const unsigned char * const end = (const unsigned char *)str + len; @@ -574,7 +563,6 @@ S_perl_hash_old_one_at_a_time(const unsigned char * const seed, const unsigned c hash ^= (hash >> 11); return (hash + (hash << 15)); } -#endif /* defined(PERL_HASH_FUNC_ONE_AT_A_TIME_OLD) */ #ifdef PERL_HASH_FUNC_MURMUR_HASH_64A /* This code is from Austin Appleby and is in the public domain. |