summaryrefslogtreecommitdiff
path: root/configmgr
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2024-02-06 12:27:45 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2024-02-06 17:07:23 +0100
commit0a5d4dc25c5521de221f63dbc47c6ba79a51f8fb (patch)
treec076915c9fef892c3e9e14c55b8c1593d09f6b43 /configmgr
parentb9a46c1ec295fe3227a5adb864c849e55838e89e (diff)
elide some OString temporaries
Change-Id: I2ecb6af11c95605c84e935b850fe94a1831a1497 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163043 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'configmgr')
-rw-r--r--configmgr/source/valueparser.cxx33
1 files changed, 21 insertions, 12 deletions
diff --git a/configmgr/source/valueparser.cxx b/configmgr/source/valueparser.cxx
index 6b9faf6edbe0..c81d975e474c 100644
--- a/configmgr/source/valueparser.cxx
+++ b/configmgr/source/valueparser.cxx
@@ -80,15 +80,21 @@ bool parseValue(xmlreader::Span const & text, sal_Bool * value) {
bool parseValue(xmlreader::Span const & text, sal_Int16 * value) {
assert(text.is() && value != nullptr);
// For backwards compatibility, support hexadecimal values:
- sal_Int32 n =
+ bool bStartWithHexPrefix =
rtl_str_shortenedCompareIgnoreAsciiCase_WithLength(
text.begin, text.length, RTL_CONSTASCII_STRINGPARAM("0X"),
- RTL_CONSTASCII_LENGTH("0X")) == 0 ?
- static_cast< sal_Int32 >(
- OString(
+ RTL_CONSTASCII_LENGTH("0X")) == 0;
+ sal_Int32 n;
+ if (bStartWithHexPrefix)
+ {
+ std::string_view sView(
text.begin + RTL_CONSTASCII_LENGTH("0X"),
- text.length - RTL_CONSTASCII_LENGTH("0X")).toUInt32(16)) :
- OString(text.begin, text.length).toInt32();
+ text.length - RTL_CONSTASCII_LENGTH("0X"));
+ n = o3tl::toUInt32(sView, 16);
+ }
+ else
+ n = o3tl::toInt32(std::string_view(text.begin, text.length));
+
//TODO: check valid lexical representation
if (n >= SAL_MIN_INT16 && n <= SAL_MAX_INT16) {
*value = static_cast< sal_Int16 >(n);
@@ -122,15 +128,18 @@ bool parseValue(xmlreader::Span const & text, sal_Int32 * value) {
bool parseValue(xmlreader::Span const & text, sal_Int64 * value) {
assert(text.is() && value != nullptr);
// For backwards compatibility, support hexadecimal values:
- *value =
+ bool bStartWithHexPrefix =
rtl_str_shortenedCompareIgnoreAsciiCase_WithLength(
text.begin, text.length, RTL_CONSTASCII_STRINGPARAM("0X"),
- RTL_CONSTASCII_LENGTH("0X")) == 0 ?
- static_cast< sal_Int64 >(
- OString(
+ RTL_CONSTASCII_LENGTH("0X")) == 0;
+ if (bStartWithHexPrefix)
+ {
+ OString sSuffix(
text.begin + RTL_CONSTASCII_LENGTH("0X"),
- text.length - RTL_CONSTASCII_LENGTH("0X")).toUInt64(16)) :
- OString(text.begin, text.length).toInt64();
+ text.length - RTL_CONSTASCII_LENGTH("0X"));
+ *value = static_cast< sal_Int64 >(sSuffix.toUInt64(16));
+ }
+ else *value = o3tl::toInt64(std::string_view(text.begin, text.length));
//TODO: check valid lexical representation
return true;
}