summaryrefslogtreecommitdiff
path: root/comphelper/source
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2019-08-07 12:49:31 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-08-07 20:12:40 +0200
commit66661417ff019831cbe7e647be2df1a4328ec2e6 (patch)
tree2ce5611b3083c93501d614e7a0fb1f7135376c84 /comphelper/source
parent9a66b452ede70a25cd6fc8a72772a71b0ee7957a (diff)
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@collabora.co.uk>
Diffstat (limited to 'comphelper/source')
-rw-r--r--comphelper/source/misc/string.cxx16
1 files changed, 11 insertions, 5 deletions
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)
{