summaryrefslogtreecommitdiff
path: root/sax
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
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')
-rw-r--r--sax/qa/cppunit/xmlimport.cxx2
-rw-r--r--sax/source/tools/converter.cxx32
2 files changed, 18 insertions, 16 deletions
diff --git a/sax/qa/cppunit/xmlimport.cxx b/sax/qa/cppunit/xmlimport.cxx
index 6ef6c81626cd..9d7832b8c4b6 100644
--- a/sax/qa/cppunit/xmlimport.cxx
+++ b/sax/qa/cppunit/xmlimport.cxx
@@ -368,7 +368,7 @@ void XMLImportTest::setUp()
namespaceArgs[0] <<= OUString( "registerNamespaces" );
for (sal_Int32 i = 1; i <= nNamespaceCount; i++ )
{
- css::beans::Pair<OUString, sal_Int32> rPair( DummyTokenHandler::namespaceURIs[i - 1], i << 16 );
+ css::beans::Pair<OUString, sal_Int32> rPair( OUString(DummyTokenHandler::namespaceURIs[i - 1]), i << 16 );
namespaceArgs[i] <<= rPair;
}
xInit->initialize( namespaceArgs );
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 );
}