From 378fe693a1ef51500db21b11ff05a8018c5f0e55 Mon Sep 17 00:00:00 2001 From: dominic <510002+dmah42@users.noreply.github.com> Date: Wed, 24 Jul 2024 14:25:32 +0100 Subject: [PATCH] Use log2 now that NDK requires at least API 21 which includes it. (#1822) Fixes #1820 --- src/complexity.cc | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/complexity.cc b/src/complexity.cc index eee31226..63acd504 100644 --- a/src/complexity.cc +++ b/src/complexity.cc @@ -27,7 +27,6 @@ namespace benchmark { // Internal function to calculate the different scalability forms BigOFunc* FittingCurve(BigO complexity) { - static const double kLog2E = 1.44269504088896340736; switch (complexity) { case oN: return [](IterationCount n) -> double { return static_cast(n); }; @@ -36,15 +35,12 @@ BigOFunc* FittingCurve(BigO complexity) { case oNCubed: return [](IterationCount n) -> double { return std::pow(n, 3); }; case oLogN: - /* Note: can't use log2 because Android's GNU STL lacks it */ - return [](IterationCount n) { - return kLog2E * std::log(static_cast(n)); + return [](IterationCount n) -> double { + return std::log2(static_cast(n)); }; case oNLogN: - /* Note: can't use log2 because Android's GNU STL lacks it */ - return [](IterationCount n) { - return kLog2E * static_cast(n) * - std::log(static_cast(n)); + return [](IterationCount n) -> double { + return static_cast(n) * std::log2(static_cast(n)); }; case o1: default: