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

Commitfde7c01

Browse files
committed
Silence warning in older versions of Valgrind
Due to misunderstanding on my part, commit235328e did not go farenough to silence older versions of Valgrind. For those, it was the bitscan that was problematic, not the subsequent bit-masking operation. Tofix, use the unaligned path for the trailing bytes. Since we don't havea bit scan here anymore, also remove some comments and endian-specificcoding around that.Reported-by: Anton A. Melnikov <a.melnikov@postgrespro.ru>Discussion:https://postgr.es/m/f3aa2d45-3b28-41c5-9499-a1bc30e0f8ec@postgrespro.ruBackpatch-through: 17
1 parent16eff42 commitfde7c01

File tree

1 file changed

+3
-23
lines changed

1 file changed

+3
-23
lines changed

‎src/include/common/hashfn_unstable.h

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
#ifndefHASHFN_UNSTABLE_H
1515
#defineHASHFN_UNSTABLE_H
1616

17-
#include"port/pg_bitutils.h"
18-
#include"port/pg_bswap.h"
1917

2018
/*
2119
* fasthash is a modification of code taken from
@@ -262,26 +260,13 @@ fasthash_accum_cstring_aligned(fasthash_state *hs, const char *str)
262260

263261
/*
264262
* For every chunk of input, check for zero bytes before mixing into the
265-
* hash. The chunk with zeros must contain the NUL terminator. We arrange
266-
* so that zero_byte_low tells us not only that a zero exists, but also
267-
* where it is, so we can hash the remainder of the string.
268-
*
269-
* The haszero64 calculation will set bits corresponding to the lowest
270-
* byte where a zero exists, so that suffices for little-endian machines.
271-
* For big-endian machines, we would need bits set for the highest zero
272-
* byte in the chunk, since the trailing junk past the terminator could
273-
* contain additional zeros. haszero64 does not give us that, so we
274-
* byteswap the chunk first.
263+
* hash. The chunk with zeros must contain the NUL terminator.
275264
*/
276265
for (;;)
277266
{
278267
uint64chunk=*(uint64*)str;
279268

280-
#ifdefWORDS_BIGENDIAN
281-
zero_byte_low=haszero64(pg_bswap64(chunk));
282-
#else
283269
zero_byte_low=haszero64(chunk);
284-
#endif
285270
if (zero_byte_low)
286271
break;
287272

@@ -290,13 +275,8 @@ fasthash_accum_cstring_aligned(fasthash_state *hs, const char *str)
290275
str+=FH_SIZEOF_ACCUM;
291276
}
292277

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);
278+
/* mix in remaining bytes */
279+
remainder=fasthash_accum_cstring_unaligned(hs,str);
300280
str+=remainder;
301281

302282
returnstr-start;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp