From 02c5091c905964b529020070b4b24616d8a3fbd8 Mon Sep 17 00:00:00 2001 From: Michael Wegner Date: Sat, 8 Sep 2018 15:36:00 -0700 Subject: cmCTestRunTest: Simplify number width computation Use a real logarithm implementation. --- Source/CTest/cmCTestRunTest.h | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/Source/CTest/cmCTestRunTest.h b/Source/CTest/cmCTestRunTest.h index 7e80157..8e24834 100644 --- a/Source/CTest/cmCTestRunTest.h +++ b/Source/CTest/cmCTestRunTest.h @@ -5,6 +5,7 @@ #include "cmConfigure.h" // IWYU pragma: keep +#include #include #include #include @@ -118,14 +119,7 @@ private: inline int getNumWidth(size_t n) { - int numWidth = 1; - if (n >= 10) { - numWidth = 2; - } - if (n >= 100) { - numWidth = 3; - } - return numWidth; + return static_cast(std::log10(n)) + 1; } #endif -- cgit v0.12