sc/source/core/tool/interpr1.cxx | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-)
New commits: commit 664d40fb24bf500a22efd1f1aff58a96b3c3cf2c Author: Winfried Donkers <winfrieddonk...@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 <er...@redhat.com> Tested-by: Eike Rathke <er...@redhat.com> (cherry picked from commit c5d0cffbf42f41349a8575ba52456d9cb07e91c7) Reviewed-on: https://gerrit.libreoffice.org/45598 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 ); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits