From 3098b888f45a8bbd6bd14a0137e9f5051c202cba Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Tue, 13 Apr 2021 11:30:25 +0200 Subject: [PATCH] STYLE: Use DoubleToStringConverter::ToShortestString overload set Simplified ITK's `FloatingPointNumberToString` implementation by using `DoubleToStringConverter::ToShortestString` overload set, proposed by pull request https://github.com/google/double-conversion/pull/159 Related to issue https://github.com/google/double-conversion/issues/160 "Add generic (template) methods for to_string (float or double)", opened by Florian Loitsch (floitsch). --- Modules/Core/Common/src/itkNumberToString.cxx | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/Modules/Core/Common/src/itkNumberToString.cxx b/Modules/Core/Common/src/itkNumberToString.cxx index a739e45c2de..46cf74efd33 100644 --- a/Modules/Core/Common/src/itkNumberToString.cxx +++ b/Modules/Core/Common/src/itkNumberToString.cxx @@ -23,23 +23,6 @@ namespace { -bool -ConvertToShortest(const double_conversion::DoubleToStringConverter & converter, - const double val, - double_conversion::StringBuilder & builder) -{ - return converter.ToShortest(val, &builder); -} - -bool -ConvertToShortest(const double_conversion::DoubleToStringConverter & converter, - const float val, - double_conversion::StringBuilder & builder) -{ - // Call the converter member function that is specific for single-precision `float`. - return converter.ToShortestSingle(val, &builder); -} - template std::string FloatingPointNumberToString(const TValue val) @@ -52,7 +35,7 @@ FloatingPointNumberToString(const TValue val) double_conversion::StringBuilder builder(buf, sizeof(buf)); - if (!ConvertToShortest(double_conversion::DoubleToStringConverter::EcmaScriptConverter(), val, builder)) + if (!double_conversion::DoubleToStringConverter::EcmaScriptConverter().ToShortestString(val, &builder)) { itkGenericExceptionMacro(<< "Conversion failed for " << val); }