summaryrefslogtreecommitdiff
path: root/sax/source
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2020-12-17 22:02:06 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-12-19 17:53:06 +0100
commit46c5de832868d2812448b2caace3eeaa9237b9f6 (patch)
tree6f25538cfb7a0def54ff7ac5b6b17eb22a76178a /sax/source
parent6dd1d2268487920e8bda44dfd169a5bda4d62f13 (diff)
make *String(string_view) constructors explicit
to make it more obvious when we are constructing heap OUStrings code and potentially inadvertently throwing away performance. And fix a handful of places so revealed. Change-Id: I0cf390f78026f8a670aaab53424cd31510633051 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107923 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sax/source')
-rw-r--r--sax/source/tools/converter.cxx32
1 files changed, 17 insertions, 15 deletions
diff --git a/sax/source/tools/converter.cxx b/sax/source/tools/converter.cxx
index 8c59586cea38..de2c66dc7435 100644
--- a/sax/source/tools/converter.cxx
+++ b/sax/source/tools/converter.cxx
@@ -899,27 +899,26 @@ void Converter::convertDouble( OUStringBuffer& rBuffer, double fNumber)
bool Converter::convertDouble(double& rValue,
std::u16string_view rString, sal_Int16 nSourceUnit, sal_Int16 nTargetUnit)
{
- rtl_math_ConversionStatus eStatus;
- rValue = ::rtl::math::stringToDouble( rString, '.', ',', &eStatus );
-
- if(eStatus == rtl_math_ConversionStatus_Ok)
- {
- OUStringBuffer sUnit;
- // fdo#48969: switch source and target because factor is used to divide!
- double const fFactor =
- GetConversionFactor(sUnit, nTargetUnit, nSourceUnit);
- if(fFactor != 1.0 && fFactor != 0.0)
- rValue /= fFactor;
- }
+ if (!convertDouble(rValue, rString))
+ return false;
- return ( eStatus == rtl_math_ConversionStatus_Ok );
+ OUStringBuffer sUnit;
+ // fdo#48969: switch source and target because factor is used to divide!
+ double const fFactor =
+ GetConversionFactor(sUnit, nTargetUnit, nSourceUnit);
+ if(fFactor != 1.0 && fFactor != 0.0)
+ rValue /= fFactor;
+ return true;
}
/** convert string to double number (using ::rtl::math) */
bool Converter::convertDouble(double& rValue, std::u16string_view rString)
{
rtl_math_ConversionStatus eStatus;
- rValue = ::rtl::math::stringToDouble( rString, '.', ',', &eStatus );
+ rValue = rtl_math_uStringToDouble(rString.data(),
+ rString.data() + rString.size(),
+ /*cDecSeparator*/'.', /*cGroupSeparator*/',',
+ &eStatus, nullptr);
return ( eStatus == rtl_math_ConversionStatus_Ok );
}
@@ -927,7 +926,10 @@ bool Converter::convertDouble(double& rValue, std::u16string_view rString)
bool Converter::convertDouble(double& rValue, std::string_view rString)
{
rtl_math_ConversionStatus eStatus;
- rValue = ::rtl::math::stringToDouble( rString, '.', ',', &eStatus );
+ rValue = rtl_math_stringToDouble(rString.data(),
+ rString.data() + rString.size(),
+ /*cDecSeparator*/'.', /*cGroupSeparator*/',',
+ &eStatus, nullptr);
return ( eStatus == rtl_math_ConversionStatus_Ok );
}