Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f1af75c commit fd734f3Copy full SHA for fd734f3
src/backend/lib/hyperloglog.c
@@ -49,6 +49,7 @@
49
#include <math.h>
50
51
#include "lib/hyperloglog.h"
52
+#include "port/pg_bitutils.h"
53
54
#define POW_2_32 (4294967296.0)
55
#define NEG_POW_2_32 (-4294967296.0)
@@ -242,11 +243,13 @@ rho(uint32 x, uint8 b)
242
243
{
244
uint8 j = 1;
245
- while (j <= b && !(x & 0x80000000))
246
- {
247
- j++;
248
- x <<= 1;
249
- }
+ if (x == 0)
+ return b + 1;
+
+ j = 32 - pg_leftmost_one_pos32(x);
250
251
+ if (j > b)
252
253
254
return j;
255
}
0 commit comments