diff options
author | Michael Stahl <mstahl@redhat.com> | 2015-03-09 23:56:24 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2015-03-10 19:10:53 +0000 |
commit | cfaeddd9ed07fad75182eb0cd040e63d08502b5e (patch) | |
tree | c90f5545e99c144df6edb2d6d90cf37e1211f228 /i18npool | |
parent | 4bae2ea3b57cb88b34bf8a9eade7ab0a950e0185 (diff) |
tdf#89665: i18npool: speed up TextSearch::searchBackward()
There does not appear to be a good reason why searchBackward()
needs to call transliterate() on the entire passed string, so don't do that,
as in the previous commit for the other direction.
Change-Id: Iadfca806da89bf8825e5a3df7fcad64ea08d7f9c
(cherry picked from commit 666fb8b7bc210be6d785515bc7660e5a5d19b82e)
Reviewed-on: https://gerrit.libreoffice.org/14827
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'i18npool')
-rw-r--r-- | i18npool/source/search/textsearch.cxx | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/i18npool/source/search/textsearch.cxx b/i18npool/source/search/textsearch.cxx index 7245e9a6a4ab..959227dfa817 100644 --- a/i18npool/source/search/textsearch.cxx +++ b/i18npool/source/search/textsearch.cxx @@ -328,25 +328,22 @@ SearchResult TextSearch::searchBackward( const OUString& searchStr, sal_Int32 st SearchResult sres; OUString in_str(searchStr); - sal_Int32 newStartPos = startPos; - sal_Int32 newEndPos = endPos; bUsePrimarySrchStr = true; if ( xTranslit.is() ) { // apply only simple 1<->1 transliteration here - com::sun::star::uno::Sequence <sal_Int32> offset( in_str.getLength()); - in_str = xTranslit->transliterate( searchStr, 0, in_str.getLength(), offset ); + com::sun::star::uno::Sequence<sal_Int32> offset(startPos - endPos); + in_str = xTranslit->transliterate( searchStr, endPos, startPos - endPos, offset ); // JP 20.6.2001: also the start and end positions must be corrected! - if( startPos < searchStr.getLength() ) - newStartPos = FindPosInSeq_Impl( offset, startPos ); - else - newStartPos = in_str.getLength(); + sal_Int32 const newStartPos = (startPos < searchStr.getLength()) + ? FindPosInSeq_Impl( offset, startPos ) + : in_str.getLength(); - if( endPos ) - newEndPos = FindPosInSeq_Impl( offset, endPos ); + sal_Int32 const newEndPos = + (endPos == 0) ? 0 : FindPosInSeq_Impl( offset, endPos ); sres = (this->*fnBackward)( in_str, newStartPos, newEndPos ); @@ -360,14 +357,14 @@ SearchResult TextSearch::searchBackward( const OUString& searchStr, sal_Int32 st for ( sal_Int32 k = 0; k < nGroups; k++ ) { const sal_Int32 nStart = sres.startOffset[k]; - if (nStart > 0) + if (endPos > 0 || nStart > 0) sres.startOffset[k] = offset[(nStart <= nOffsets ? nStart : nOffsets) - 1] + 1; // JP 20.6.2001: end is ever exclusive and then don't return // the position of the next character - return the // next position behind the last found character! // "a b c" find "b" must return 2,3 and not 2,4!!! const sal_Int32 nStop = sres.endOffset[k]; - if (nStop > 0) + if (endPos > 0 || nStop > 0) sres.endOffset[k] = (nStop < nOffsets ? offset[nStop] : (offset[nOffsets - 1] + 1)); } } |