@@ -130,49 +130,6 @@ void lj_str_resize(lua_State *L, MSize newmask)
130130 g -> strhash = newhash ;
131131}
132132
133- static MSize
134- lj_str_original_hash (const char * str , size_t lenx )
135- {
136- MSize len = (MSize )lenx ;
137- MSize a , b , h = len ;
138-
139- /* Compute string hash. Constants taken from lookup3 hash by Bob Jenkins. */
140- if (len >= 4 ) { /* Caveat: unaligned access! */
141- a = lj_getu32 (str );
142- h ^= lj_getu32 (str + len - 4 );
143- b = lj_getu32 (str + (len >>1 )- 2 );
144- h ^= b ; h -= lj_rol (b , 14 );
145- b += lj_getu32 (str + (len >>2 )- 1 );
146- } else if (len > 0 ) {
147- a = * (const uint8_t * )str ;
148- h ^= * (const uint8_t * )(str + len - 1 );
149- b = * (const uint8_t * )(str + (len >>1 ));
150- h ^= b ; h -= lj_rol (b , 14 );
151- } else {
152- return 0 ;
153- }
154-
155- a ^= h ; a -= lj_rol (h , 11 );
156- b ^= a ; b -= lj_rol (a , 25 );
157- h ^= b ; h -= lj_rol (b , 16 );
158-
159- return h ;
160- }
161-
162- MSize
163- lj_str_indep_hash (GCstr * str )
164- {
165- return lj_str_original_hash (strdata (str ), str -> len );
166- }
167-
168- #include "x64/src/lj_str_hash_x64.h"
169-
170- #if defined(LJ_ARCH_STR_HASH )
171- #define LJ_STR_HASH LJ_ARCH_STR_HASH
172- #else
173- #define LJ_STR_HASH lj_str_original_hash
174- #endif
175-
176133/* Intern a string and return string object. */
177134GCstr * lj_str_new (lua_State * L , const char * str , size_t lenx )
178135{
@@ -189,7 +146,12 @@ GCstr *lj_str_new(lua_State *L, const char *str, size_t lenx)
189146 return & g -> strempty ;
190147 }
191148
192- h = LJ_STR_HASH (str , lenx );
149+ #if LJ_OR_STRHASHCRC32
150+ lua_assert (g -> strhashfn != NULL );
151+ h = g -> strhashfn (str , lenx );
152+ #else
153+ h = lj_str_hash_orig (str , lenx );
154+ #endif
193155
194156 /* Check if the string has already been interned. */
195157 o = gcref (g -> strhash [h & g -> strmask ]);
0 commit comments