From 66661417ff019831cbe7e647be2df1a4328ec2e6 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 7 Aug 2019 12:49:31 +0200 Subject: 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 --- comphelper/source/misc/string.cxx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'comphelper') 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(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) { -- cgit