summaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/acl.c
diff options
context:
space:
mode:
authorNathan Bossart <nathan@postgresql.org>2025-03-12 15:01:52 -0500
committerNathan Bossart <nathan@postgresql.org>2025-03-12 15:01:52 -0500
commit025e7e1eb4b884a187ade19f2ed479b256306a82 (patch)
treef4e47c7a00b00b57c4f8da5eda27d556c5e08f59 /src/backend/utils/adt/acl.c
parentff79b5b2aba02d720f9b7fff644dd50ce07b8c6e (diff)
Remove count_one_bits() in acl.c.
The only caller, select_best_grantor(), can instead use pg_popcount64(). This isn't performance-critical code, but we might as well use the centralized implementation. While at it, add some test coverage for this part of select_best_grantor(). Reviewed-by: Álvaro Herrera <alvherre@alvh.no-ip.org> Discussion: https://postgr.es/m/Z9GtL7Nm6hsYyJnF%40nathan
Diffstat (limited to 'src/backend/utils/adt/acl.c')
-rw-r--r--src/backend/utils/adt/acl.c20
1 files changed, 1 insertions, 19 deletions
diff --git a/src/backend/utils/adt/acl.c b/src/backend/utils/adt/acl.c
index 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)
{