mathlib.h: replaced slow `std::ostringstream` with `std::to_string()` in `MathLib::toString()` (#4382)
This commit is contained in:
parent
80a486dda0
commit
f138df2909
|
@ -23,7 +23,6 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
/// @addtogroup Core
|
||||
|
@ -74,9 +73,7 @@ public:
|
|||
static biguint toULongNumber(const std::string & str);
|
||||
|
||||
template<class T> static std::string toString(T value) {
|
||||
std::ostringstream result;
|
||||
result << value;
|
||||
return result.str();
|
||||
return std::to_string(value);
|
||||
}
|
||||
static double toDoubleNumber(const std::string & str);
|
||||
|
||||
|
|
|
@ -1217,11 +1217,19 @@ private:
|
|||
ASSERT_EQUALS("0.0", MathLib::toString(+0.0));
|
||||
ASSERT_EQUALS("0.0", MathLib::toString(-0.0));
|
||||
// float (trailing f or F)
|
||||
ASSERT_EQUALS("0", MathLib::toString(+0.0f));
|
||||
ASSERT_EQUALS("-0", MathLib::toString(-0.0F));
|
||||
ASSERT_EQUALS("0.000000", MathLib::toString(0.0f));
|
||||
ASSERT_EQUALS("0.000000", MathLib::toString(+0.0f));
|
||||
ASSERT_EQUALS("-0.000000", MathLib::toString(-0.0f));
|
||||
ASSERT_EQUALS("0.000000", MathLib::toString(0.0F));
|
||||
ASSERT_EQUALS("0.000000", MathLib::toString(+0.0F));
|
||||
ASSERT_EQUALS("-0.000000", MathLib::toString(-0.0F));
|
||||
// double (tailing l or L)
|
||||
ASSERT_EQUALS("0", MathLib::toString(+0.0l));
|
||||
ASSERT_EQUALS("-0", MathLib::toString(-0.0L));
|
||||
ASSERT_EQUALS("0.000000", MathLib::toString(0.0l));
|
||||
ASSERT_EQUALS("0.000000", MathLib::toString(+0.0l));
|
||||
ASSERT_EQUALS("-0.000000", MathLib::toString(-0.0l));
|
||||
ASSERT_EQUALS("0.000000", MathLib::toString(0.0L));
|
||||
ASSERT_EQUALS("0.000000", MathLib::toString(+0.0L));
|
||||
ASSERT_EQUALS("-0.000000", MathLib::toString(-0.0L));
|
||||
}
|
||||
|
||||
void CPP14DigitSeparators() const { // Ticket #7137, #7565
|
||||
|
|
Loading…
Reference in New Issue