summaryrefslogtreecommitdiff
path: root/configmgr
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2024-02-05 14:32:01 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2024-02-05 15:10:52 +0100
commit7ee4ea5c098d4e97bd5b3aa5998f6885da0d74fe (patch)
treec0418c1800b9e94f85a19fc1d02b5d5f10d7620c /configmgr
parentc58f42c1bd2ec1b24f02a27c952e88d43ee07beb (diff)
reduce unnecessary OString temporaries
spotted while profiling tdf#108037 Change-Id: I66afa79d7da94c1d3c7d1695ce9c5cf902e1429e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163002 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'configmgr')
-rw-r--r--configmgr/source/valueparser.cxx25
1 files changed, 16 insertions, 9 deletions
diff --git a/configmgr/source/valueparser.cxx b/configmgr/source/valueparser.cxx
index 249c1c1dbdcb..6b9faf6edbe0 100644
--- a/configmgr/source/valueparser.cxx
+++ b/configmgr/source/valueparser.cxx
@@ -25,6 +25,7 @@
#include <com/sun/star/uno/RuntimeException.hpp>
#include <com/sun/star/uno/Sequence.hxx>
#include <comphelper/sequence.hxx>
+#include <o3tl/string_view.hxx>
#include <rtl/math.h>
#include <rtl/string.h>
#include <rtl/string.hxx>
@@ -99,16 +100,22 @@ bool parseValue(xmlreader::Span const & text, sal_Int16 * value) {
bool parseValue(xmlreader::Span const & text, sal_Int32 * value) {
assert(text.is() && value != nullptr);
// For backwards compatibility, support hexadecimal values:
- *value =
- rtl_str_shortenedCompareIgnoreAsciiCase_WithLength(
+ bool bStartWithHexPrefix = rtl_str_shortenedCompareIgnoreAsciiCase_WithLength(
text.begin, text.length, RTL_CONSTASCII_STRINGPARAM("0X"),
- RTL_CONSTASCII_LENGTH("0X")) == 0 ?
- static_cast< sal_Int32 >(
- OString(
- text.begin + RTL_CONSTASCII_LENGTH("0X"),
- text.length - RTL_CONSTASCII_LENGTH("0X")).toUInt32(16)) :
- OString(text.begin, text.length).toInt32();
- //TODO: check valid lexical representation
+ RTL_CONSTASCII_LENGTH("0X")) == 0;
+
+ if (bStartWithHexPrefix)
+ {
+ std::string_view sView(text.begin + RTL_CONSTASCII_LENGTH("0X"),
+ text.length - RTL_CONSTASCII_LENGTH("0X"));
+ *value = static_cast< sal_Int32 >(o3tl::toUInt32(sView, 16));
+ }
+ else
+ {
+ std::string_view sView(text.begin, text.length);
+ *value = o3tl::toInt32(sView);
+ }
+ //TODO: check valid lexical representation
return true;
}