mirror of
https://github.com/postgres/postgres.git
synced 2025-06-16 06:01:02 +03:00
Use bitwise rotate functions in more places
There were a number of places in the code that used bespoke bit-twiddling expressions to do bitwise rotation. While we've had pg_rotate_right32() for a while now, we hadn't gotten around to standardizing on that. Do so now. Since many potential call sites look more natural with the "left" equivalent, add that function too. Reviewed by Tom Lane and Yugo Nagata Discussion: https://www.postgresql.org/message-id/CAFBsxsH7c1LC0CGZ0ADCBXLHU5-%3DKNXx-r7tHYPAW51b2HK4Qw%40mail.gmail.com
This commit is contained in:
@ -166,8 +166,8 @@ MemoizeHash_hash(struct memoize_hash *tb, const MemoizeKey *key)
|
||||
{
|
||||
for (int i = 0; i < numkeys; i++)
|
||||
{
|
||||
/* rotate hashkey left 1 bit at each step */
|
||||
hashkey = (hashkey << 1) | ((hashkey & 0x80000000) ? 1 : 0);
|
||||
/* combine successive hashkeys by rotating */
|
||||
hashkey = pg_rotate_left32(hashkey, 1);
|
||||
|
||||
if (!pslot->tts_isnull[i]) /* treat nulls as having hash key 0 */
|
||||
{
|
||||
@ -189,8 +189,8 @@ MemoizeHash_hash(struct memoize_hash *tb, const MemoizeKey *key)
|
||||
|
||||
for (int i = 0; i < numkeys; i++)
|
||||
{
|
||||
/* rotate hashkey left 1 bit at each step */
|
||||
hashkey = (hashkey << 1) | ((hashkey & 0x80000000) ? 1 : 0);
|
||||
/* combine successive hashkeys by rotating */
|
||||
hashkey = pg_rotate_left32(hashkey, 1);
|
||||
|
||||
if (!pslot->tts_isnull[i]) /* treat nulls as having hash key 0 */
|
||||
{
|
||||
|
Reference in New Issue
Block a user