From: Nathan Bossart <nathandbossart@gmail.com>
To: pgsql-hackers@postgresql.org
Subject: remove open-coded popcount in acl.c
Date: Wed, 12 Mar 2025 10:50:07 -0500
Message-ID: <Z9GtL7Nm6hsYyJnF@nathan> (raw)
There's a count_one_bits() function in acl.c that can be replaced with a
call to pg_popcount64(). This isn't performance-critical code, but IMHO we
might as well use the centralized implementation.
--
nathan
Attachments:v1-0001-Remove-open-coded-popcount-in-acl.c.patch (text/plain, 1.2K) download
From 932fac13bf168571b145a54c29d9ac28ca2a070f Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
Date: Wed, 12 Mar 2025 10:45:12 -0500
Subject: [PATCH v1 1/1] Remove open-coded popcount in acl.c.
---
src/backend/utils/adt/acl.c | 20 +-------------------
1 file changed, 1 insertion(+), 19 deletions(-)
diff --git a/src/backend/utils/adt/acl.c b/src/backend/utils/adt/acl.cindex 6a76550a5e2..ba14713fef2 100644--- a/src/backend/utils/adt/acl.c+++ b/src/backend/utils/adt/acl.c@@ -5432,24 +5432,6 @@ select_best_admin(Oid member, Oid role)
return admin_role;
}
--/* does what it says ... */-static int-count_one_bits(AclMode mask)-{- int nbits = 0;-- /* this code relies on AclMode being an unsigned type */- while (mask)- {- if (mask & 1)- nbits++;- mask >>= 1;- }- return nbits;-}--
/*
* Select the effective grantor ID for a GRANT or REVOKE operation.
*
@@ -5532,7 +5514,7 @@ select_best_grantor(Oid roleId, AclMode privileges,
*/
if (otherprivs != ACL_NO_RIGHTS)
{
- int nnewrights = count_one_bits(otherprivs);+ int nnewrights = pg_popcount64(otherprivs);
if (nnewrights > nrights)
{
--
2.39.5 (Apple Git-154)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: nathandbossart@gmail.com
Subject: Re: remove open-coded popcount in acl.c
In-Reply-To: <Z9GtL7Nm6hsYyJnF@nathan>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox