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:
@@ -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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user