diff options
author | Winfried Donkers <winfrieddonkers@libreoffice.org> | 2017-11-29 17:43:14 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2017-12-01 11:25:14 +0100 |
commit | 664d40fb24bf500a22efd1f1aff58a96b3c3cf2c (patch) | |
tree | 7a1c3009297df102e5a0932fc3cc7adefe506318 | |
parent | 937e292367d447a709d15646a2a354aade5ad6aa (diff) |
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@redhat.com>
Tested-by: Eike Rathke <erack@redhat.com>
(cherry picked from commit c5d0cffbf42f41349a8575ba52456d9cb07e91c7)
Reviewed-on: https://gerrit.libreoffice.org/45598
-rw-r--r-- | sc/source/core/tool/interpr1.cxx | 18 |
1 files changed, 5 insertions, 13 deletions
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 ); |