1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-18 02:02:55 +03:00

Modify additional power 2 calculations to use new helper functions

2nd pass of modifying various places which obtain the next power
of 2 of a number and make them use the new functions added in
f0705bb62.

In passing, also modify num_combinations(). This can be implemented
using simple bitshifting rather than looping.

Reviewed-by: John Naylor
Discussion: https://postgr.es/m/20200114173553.GE32763%40fetter.org
This commit is contained in:
David Rowley
2020-04-08 18:29:51 +12:00
parent c0187869a0
commit 02a2e8b442
5 changed files with 16 additions and 38 deletions

View File

@@ -576,15 +576,7 @@ n_choose_k(int n, int k)
static int
num_combinations(int n)
{
int k;
int ncombs = 1;
for (k = 1; k <= n; k++)
ncombs *= 2;
ncombs -= (n + 1);
return ncombs;
return (1 << n) - (n + 1);
}
/*