[Libreoffice-commits] core.git: Branch 'libreoffice-6-3' - comphelper/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Wed Aug 7 20:14:03 UTC 2019


 comphelper/source/misc/string.cxx |   16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

New commits:
commit d2c728ea3fe1c657db500dcd114069705b4759d1
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Aug 7 12:49:31 2019 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Aug 7 22:13:23 2019 +0200

    tdf#126663 speed up styles display
    
    reduce temporary OUString creation in a hotspot, reduces the time for me
    from 9s to 1s
    
    Change-Id: I0d5c479f124361661d55e78b802c04a06a3fefae
    Reviewed-on: https://gerrit.libreoffice.org/77098
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
    (cherry picked from commit 66661417ff019831cbe7e647be2df1a4328ec2e6)
    Reviewed-on: https://gerrit.libreoffice.org/77134

diff --git a/comphelper/source/misc/string.cxx b/comphelper/source/misc/string.cxx
index 98fc3d8585a7..31c8c750e8d8 100644
--- a/comphelper/source/misc/string.cxx
+++ b/comphelper/source/misc/string.cxx
@@ -143,11 +143,11 @@ sal_Int32 getTokenCount(const OUString &rIn, sal_Unicode cTok)
     return tmpl_getTokenCount<OUString, sal_Unicode>(rIn, cTok);
 }
 
-sal_uInt32 decimalStringToNumber(
-    OUString const & str )
+static sal_uInt32 decimalStringToNumber(
+    OUString const & str, sal_Int32 nStart, sal_Int32 nLength )
 {
     sal_uInt32 result = 0;
-    for( sal_Int32 i = 0 ; i < str.getLength() ; )
+    for( sal_Int32 i = nStart; i < nStart + nLength; )
     {
         sal_uInt32 c = str.iterateCodePoints(&i);
         sal_uInt32 value = 0;
@@ -240,6 +240,12 @@ sal_uInt32 decimalStringToNumber(
     return result;
 }
 
+sal_uInt32 decimalStringToNumber(
+    OUString const & str )
+{
+    return decimalStringToNumber(str, 0, str.getLength());
+}
+
 using namespace ::com::sun::star;
 
 // convert between sequence of string and comma separated string
@@ -342,8 +348,8 @@ sal_Int32 compareNatural( const OUString & rLHS, const OUString & rRHS,
         //numbers outside of the normal 0-9 range, e.g. see GetLocalizedChar in
         //vcl
 
-        sal_uInt32 nLHS = comphelper::string::decimalStringToNumber(rLHS.copy(nLHSFirstDigitPos, nLHSChunkLen));
-        sal_uInt32 nRHS = comphelper::string::decimalStringToNumber(rRHS.copy(nRHSFirstDigitPos, nRHSChunkLen));
+        sal_uInt32 nLHS = comphelper::string::decimalStringToNumber(rLHS, nLHSFirstDigitPos, nLHSChunkLen);
+        sal_uInt32 nRHS = comphelper::string::decimalStringToNumber(rRHS, nRHSFirstDigitPos, nRHSChunkLen);
 
         if (nLHS != nRHS)
         {


More information about the Libreoffice-commits mailing list