From fa597536e19e1aacc2cb96e12ad5f1b4d0e2d7d7 Mon Sep 17 00:00:00 2001 From: Petru Conduraru Date: Mon, 6 Jul 2026 13:54:34 +0300 Subject: [PATCH] IfcParse: drop ostringstream from format_double per review #7696 std::to_chars is locale-independent, so the ostringstream and imbue(locale) are no longer needed. Build the REAL string with plain std::string operations. Output is unchanged (verified in standalone compile: same shortest values, all round-trip). Addresses review feedback on #8309. Co-Authored-By: Claude Fable 5 --- src/ifcparse/IfcParse.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/ifcparse/IfcParse.cpp b/src/ifcparse/IfcParse.cpp index 88e1841cec..602cd909df 100644 --- a/src/ifcparse/IfcParse.cpp +++ b/src/ifcparse/IfcParse.cpp @@ -759,25 +759,24 @@ namespace { // values with noise digits (0.0174532925199433 -> 0.017453292519943299), // which rewrote every REAL and produced huge diffs when a file was // re-saved. See #7696. + // std::to_chars is locale-independent, so no ostringstream/imbue is + // needed here. char buf[64]; const auto res = std::to_chars(buf, buf + sizeof(buf), d); const std::string str(buf, res.ptr); - std::ostringstream oss; - oss.imbue(std::locale::classic()); std::string::size_type e = str.find('e'); if (e == std::string::npos) { e = str.find('E'); } - const std::string mantissa = str.substr(0, e); - oss << mantissa; - if (mantissa.find('.') == std::string::npos) { - oss << "."; + std::string result = str.substr(0, e); + if (result.find('.') == std::string::npos) { + result += '.'; } if (e != std::string::npos) { - oss << "E"; - oss << str.substr(e + 1); + result += 'E'; + result += str.substr(e + 1); } - return oss.str(); + return result; } static std::string format_binary(const boost::dynamic_bitset<>& b) {