mirror of
https://github.com/postgres/postgres.git
synced 2025-07-05 07:21:24 +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:
14
src/backend/utils/cache/catcache.c
vendored
14
src/backend/utils/cache/catcache.c
vendored
@ -26,6 +26,7 @@
|
||||
#include "catalog/pg_type.h"
|
||||
#include "common/hashfn.h"
|
||||
#include "miscadmin.h"
|
||||
#include "port/pg_bitutils.h"
|
||||
#ifdef CATCACHE_STATS
|
||||
#include "storage/ipc.h" /* for on_proc_exit */
|
||||
#endif
|
||||
@ -281,25 +282,18 @@ CatalogCacheComputeHashValue(CatCache *cache, int nkeys,
|
||||
{
|
||||
case 4:
|
||||
oneHash = (cc_hashfunc[3]) (v4);
|
||||
|
||||
hashValue ^= oneHash << 24;
|
||||
hashValue ^= oneHash >> 8;
|
||||
hashValue ^= pg_rotate_left32(oneHash, 24);
|
||||
/* FALLTHROUGH */
|
||||
case 3:
|
||||
oneHash = (cc_hashfunc[2]) (v3);
|
||||
|
||||
hashValue ^= oneHash << 16;
|
||||
hashValue ^= oneHash >> 16;
|
||||
hashValue ^= pg_rotate_left32(oneHash, 16);
|
||||
/* FALLTHROUGH */
|
||||
case 2:
|
||||
oneHash = (cc_hashfunc[1]) (v2);
|
||||
|
||||
hashValue ^= oneHash << 8;
|
||||
hashValue ^= oneHash >> 24;
|
||||
hashValue ^= pg_rotate_left32(oneHash, 8);
|
||||
/* FALLTHROUGH */
|
||||
case 1:
|
||||
oneHash = (cc_hashfunc[0]) (v1);
|
||||
|
||||
hashValue ^= oneHash;
|
||||
break;
|
||||
default:
|
||||
|
Reference in New Issue
Block a user