@@ -219,13 +219,6 @@ fasthash_accum(fasthash_state *hs, const char *k, size_t len)
219
219
#define haszero64 (v ) \
220
220
(((v) - 0x0101010101010101) & ~(v) & 0x8080808080808080)
221
221
222
- /* get first byte in memory order */
223
- #ifdef WORDS_BIGENDIAN
224
- #define firstbyte64 (v ) ((v) >> 56)
225
- #else
226
- #define firstbyte64 (v ) ((v) & 0xFF)
227
- #endif
228
-
229
222
/*
230
223
* all-purpose workhorse for fasthash_accum_cstring
231
224
*/
@@ -262,7 +255,7 @@ static inline size_t
262
255
fasthash_accum_cstring_aligned (fasthash_state * hs , const char * str )
263
256
{
264
257
const char * const start = str ;
265
- uint64 chunk ;
258
+ size_t remainder ;
266
259
uint64 zero_byte_low ;
267
260
268
261
Assert (PointerIsAligned (start , uint64 ));
@@ -282,7 +275,7 @@ fasthash_accum_cstring_aligned(fasthash_state *hs, const char *str)
282
275
*/
283
276
for (;;)
284
277
{
285
- chunk = * (uint64 * ) str ;
278
+ uint64 chunk = * (uint64 * ) str ;
286
279
287
280
#ifdef WORDS_BIGENDIAN
288
281
zero_byte_low = haszero64 (pg_bswap64 (chunk ));
@@ -297,33 +290,14 @@ fasthash_accum_cstring_aligned(fasthash_state *hs, const char *str)
297
290
str += FH_SIZEOF_ACCUM ;
298
291
}
299
292
300
- if (firstbyte64 (chunk ) != 0 )
301
- {
302
- size_t remainder ;
303
- uint64 mask ;
304
-
305
- /*
306
- * The byte corresponding to the NUL will be 0x80, so the rightmost
307
- * bit position will be in the range 15, 23, ..., 63. Turn this into
308
- * byte position by dividing by 8.
309
- */
310
- remainder = pg_rightmost_one_pos64 (zero_byte_low ) / BITS_PER_BYTE ;
311
-
312
- /*
313
- * Create a mask for the remaining bytes so we can combine them into
314
- * the hash. This must have the same result as mixing the remaining
315
- * bytes with fasthash_accum().
316
- */
317
- #ifdef WORDS_BIGENDIAN
318
- mask = ~UINT64CONST (0 ) << BITS_PER_BYTE * (FH_SIZEOF_ACCUM - remainder );
319
- #else
320
- mask = ~UINT64CONST (0 ) >> BITS_PER_BYTE * (FH_SIZEOF_ACCUM - remainder );
321
- #endif
322
- hs -> accum = chunk & mask ;
323
- fasthash_combine (hs );
324
-
325
- str += remainder ;
326
- }
293
+ /*
294
+ * The byte corresponding to the NUL will be 0x80, so the rightmost bit
295
+ * position will be in the range 7, 15, ..., 63. Turn this into byte
296
+ * position by dividing by 8.
297
+ */
298
+ remainder = pg_rightmost_one_pos64 (zero_byte_low ) / BITS_PER_BYTE ;
299
+ fasthash_accum (hs , str , remainder );
300
+ str += remainder ;
327
301
328
302
return str - start ;
329
303
}
0 commit comments