use rotate macro in more places

From: John Naylor <john(dot)naylor(at)enterprisedb(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: use rotate macro in more places
Date: 2022-02-19 13:07:58
Message-ID: CAFBsxsH7c1LC0CGZ0ADCBXLHU5-=KNXx-r7tHYPAW51b2HK4Qw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

We've accumulated a few bit-twiddling hacks to get the compiler to
emit a rotate instruction. Since we have a macro for that, let's use
it, as in the attached. I thought the new call sites would look better
with a "left" version, so I added a new macro for that. That's not
necessary, however.

Some comments now look a bit too obvious to keep around, but maybe
they should be replaced with a "why", instead of a "what":

/* rotate hashkey left 1 bit at each step */
- hashkey = (hashkey << 1) | ((hashkey &
0x80000000) ? 1 : 0);
+ hashkey = pg_rotate_left32(hashkey, 1);

--
John Naylor
EDB: http://www.enterprisedb.com

Attachment Content-Type Size
use-rotate-macros.patch text/x-patch 3.7 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Zhihong Yu 2022-02-19 13:20:14 doc: join state for merge join
Previous Message Amit Kapila 2022-02-19 10:49:39 Re: Design of pg_stat_subscription_workers vs pgstats