configmgr/source/valueparser.cxx |   25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

New commits:
commit dc6262ed969ed8a8d0ab2ff2f72ef50e43d68a75
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Mon Feb 5 14:32:01 2024 +0200
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Mon Feb 5 16:45:56 2024 +0100

    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.gran...@collabora.co.uk>
    (cherry picked from commit f2632d4766308fc015bf2cc9576835a160a2d1d6)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163011
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

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;
 }
 

Reply via email to