1
1
mirror of https://github.com/rui314/mold.git synced 2024-10-05 17:17:40 +03:00

replace pow(2,x) by ldexp(1.0,x) for performance

This commit is contained in:
Alexander Voigt 2023-07-20 09:28:35 +02:00
parent 2d25a93126
commit b685f3cab7

View File

@ -13,7 +13,7 @@ namespace mold {
i64 HyperLogLog::get_cardinality() const {
double z = 0;
for (i64 val : buckets)
z += pow(2, -val);
z += std::ldexp(1.0, -val);
return ALPHA * NBUCKETS * NBUCKETS / z;
}