[Libreoffice-commits] core.git: sc/source
Winfried Donkers
winfrieddonkers at libreoffice.org
Thu Nov 30 15:31:02 UTC 2017
sc/source/core/tool/interpr1.cxx | 18 +++++-------------
1 file changed, 5 insertions(+), 13 deletions(-)
New commits:
commit c5d0cffbf42f41349a8575ba52456d9cb07e91c7
Author: Winfried Donkers <winfrieddonkers at libreoffice.org>
Date: Wed Nov 29 17:43:14 2017 +0100
tdf#97198 follow up: improve efficiency for Calc function RIGHT.
Change-Id: Ie2d5011f9ff73bd42a6f3ced1f709fab65d23c18
Reviewed-on: https://gerrit.libreoffice.org/45517
Reviewed-by: Eike Rathke <erack at redhat.com>
Tested-by: Eike Rathke <erack at redhat.com>
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 164c1185e1b8..d3b5829a5db8 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -8901,23 +8901,15 @@ void ScInterpreter::ScRight()
n = 1;
OUString aStr = GetString().getString();
sal_Int32 nLen = aStr.getLength();
- sal_Int32 nIdx = 0;
- sal_Int32 nCnt = 0;
- while ( nIdx < nLen )
- {
- aStr.iterateCodePoints( &nIdx );
- ++nCnt;
- }
- if ( nCnt <= n )
+ if ( nLen <= n )
PushString( aStr );
else
{
- sal_Int32 nCLen = nCnt;
- nIdx = 0;
- nCnt = 0;
- while ( nIdx < nLen && n < ( nCLen - nCnt ) )
+ sal_Int32 nIdx = nLen;
+ sal_Int32 nCnt = 0;
+ while ( nIdx > 0 && n > nCnt )
{
- aStr.iterateCodePoints( &nIdx );
+ aStr.iterateCodePoints( &nIdx, -1 );
++nCnt;
}
aStr = aStr.copy( nIdx, nLen - nIdx );
More information about the Libreoffice-commits
mailing list