@@ -219,9 +219,8 @@ static inline size_t
219
219
fasthash_accum_cstring_aligned (fasthash_state * hs , const char * str )
220
220
{
221
221
const char * const start = str ;
222
- uint64 chunk ;
222
+ size_t remainder ;
223
223
uint64 zero_byte_low ;
224
- uint64 mask ;
225
224
226
225
Assert (PointerIsAligned (start , uint64 ));
227
226
@@ -240,7 +239,7 @@ fasthash_accum_cstring_aligned(fasthash_state *hs, const char *str)
240
239
*/
241
240
for (;;)
242
241
{
243
- chunk = * (uint64 * ) str ;
242
+ uint64 chunk = * (uint64 * ) str ;
244
243
245
244
#ifdef WORDS_BIGENDIAN
246
245
zero_byte_low = haszero64 (pg_bswap64 (chunk ));
@@ -255,37 +254,14 @@ fasthash_accum_cstring_aligned(fasthash_state *hs, const char *str)
255
254
str += FH_SIZEOF_ACCUM ;
256
255
}
257
256
258
- if (zero_byte_low & 0xFF )
259
- {
260
- /*
261
- * The next byte in the input is the NUL terminator, so we have
262
- * nothing to do.
263
- */
264
- }
265
- else
266
- {
267
- /*
268
- * Create a mask for the remaining bytes so we can combine them into
269
- * the hash. The mask also covers the NUL terminator, but that's
270
- * harmless. The mask could contain 0x80 in bytes corresponding to the
271
- * input past the terminator, but only where the input byte is zero or
272
- * one, so also harmless.
273
- */
274
- mask = zero_byte_low | (zero_byte_low - 1 );
275
- #ifdef WORDS_BIGENDIAN
276
- /* need to mask the upper bytes */
277
- mask = pg_bswap64 (mask );
278
- #endif
279
- hs -> accum = chunk & mask ;
280
- fasthash_combine (hs );
281
-
282
- /*
283
- * The byte corresponding to the NUL will be 0x80, so the rightmost
284
- * bit position will be in the range 15, 23, ..., 63. Turn this into
285
- * byte position by dividing by 8.
286
- */
287
- str += pg_rightmost_one_pos64 (zero_byte_low ) / BITS_PER_BYTE ;
288
- }
257
+ /*
258
+ * The byte corresponding to the NUL will be 0x80, so the rightmost bit
259
+ * position will be in the range 7, 15, ..., 63. Turn this into byte
260
+ * position by dividing by 8.
261
+ */
262
+ remainder = pg_rightmost_one_pos64 (zero_byte_low ) / BITS_PER_BYTE ;
263
+ fasthash_accum (hs , str , remainder );
264
+ str += remainder ;
289
265
290
266
return str - start ;
291
267
}
0 commit comments