aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/jsonb_util.c
diff options
context:
space:
mode:
authorJohn Naylor <john.naylor@postgresql.org>2022-02-20 13:22:08 +0700
committerJohn Naylor <john.naylor@postgresql.org>2022-02-20 13:22:08 +0700
commit4b35408f1ed59dd590f683ae0f015bbaf3b84d3d (patch)
treef0fbcde2e180f22114c14331512b8bcfacfcf5e6 /src/backend/utils/adt/jsonb_util.c
parentd7a978601d4e469f1a8f19122c049bb25fd7f096 (diff)
downloadpostgresql-4b35408f1ed59dd590f683ae0f015bbaf3b84d3d.tar.gz
postgresql-4b35408f1ed59dd590f683ae0f015bbaf3b84d3d.zip
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
Diffstat (limited to 'src/backend/utils/adt/jsonb_util.c')
-rw-r--r--src/backend/utils/adt/jsonb_util.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/backend/utils/adt/jsonb_util.c b/src/backend/utils/adt/jsonb_util.c
index 291fb722e2d..60442758b32 100644
--- a/src/backend/utils/adt/jsonb_util.c
+++ b/src/backend/utils/adt/jsonb_util.c
@@ -18,6 +18,7 @@
#include "common/hashfn.h"
#include "common/jsonapi.h"
#include "miscadmin.h"
+#include "port/pg_bitutils.h"
#include "utils/builtins.h"
#include "utils/datetime.h"
#include "utils/json.h"
@@ -1342,7 +1343,7 @@ JsonbHashScalarValue(const JsonbValue *scalarVal, uint32 *hash)
* the previous value left 1 bit, then XOR'ing in the new
* key/value/element's hash value.
*/
- *hash = (*hash << 1) | (*hash >> 31);
+ *hash = pg_rotate_left32(*hash, 1);
*hash ^= tmp;
}