@@ -219,13 +219,6 @@ fasthash_accum(fasthash_state *hs, const char *k, size_t len)
219219#define haszero64 (v ) \
220220 (((v) - 0x0101010101010101) & ~(v) & 0x8080808080808080)
221221
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-
229222/*
230223 * all-purpose workhorse for fasthash_accum_cstring
231224 */
@@ -262,7 +255,7 @@ static inline size_t
262255fasthash_accum_cstring_aligned (fasthash_state * hs , const char * str )
263256{
264257 const char * const start = str ;
265- uint64 chunk ;
258+ size_t remainder ;
266259 uint64 zero_byte_low ;
267260
268261 Assert (PointerIsAligned (start , uint64 ));
@@ -282,7 +275,7 @@ fasthash_accum_cstring_aligned(fasthash_state *hs, const char *str)
282275 */
283276 for (;;)
284277 {
285- chunk = * (uint64 * ) str ;
278+ uint64 chunk = * (uint64 * ) str ;
286279
287280#ifdef WORDS_BIGENDIAN
288281 zero_byte_low = haszero64 (pg_bswap64 (chunk ));
@@ -297,33 +290,14 @@ fasthash_accum_cstring_aligned(fasthash_state *hs, const char *str)
297290 str += FH_SIZEOF_ACCUM ;
298291 }
299292
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 ;
327301
328302 return str - start ;
329303}
0 commit comments