Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf4ad002

Browse files
committed
Revert "Speed up tail processing when hashing aligned C strings"
This reverts commit07f0f6a.This has shown failures on both Valgrind and big-endian machines,per members skink and pike.
1 parent07f0f6a commitf4ad002

File tree

1 file changed

+10
-34
lines changed

1 file changed

+10
-34
lines changed

‎src/include/common/hashfn_unstable.h

Lines changed: 10 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,8 @@ static inline size_t
219219
fasthash_accum_cstring_aligned(fasthash_state*hs,constchar*str)
220220
{
221221
constchar*conststart=str;
222-
uint64chunk;
222+
size_tremainder;
223223
uint64zero_byte_low;
224-
uint64mask;
225224

226225
Assert(PointerIsAligned(start,uint64));
227226

@@ -240,7 +239,7 @@ fasthash_accum_cstring_aligned(fasthash_state *hs, const char *str)
240239
*/
241240
for (;;)
242241
{
243-
chunk=*(uint64*)str;
242+
uint64chunk=*(uint64*)str;
244243

245244
#ifdefWORDS_BIGENDIAN
246245
zero_byte_low=haszero64(pg_bswap64(chunk));
@@ -255,37 +254,14 @@ fasthash_accum_cstring_aligned(fasthash_state *hs, const char *str)
255254
str+=FH_SIZEOF_ACCUM;
256255
}
257256

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-
#ifdefWORDS_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;
289265

290266
returnstr-start;
291267
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp