summaryrefslogtreecommitdiff
path: root/i18npool
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2015-03-09 23:56:24 +0100
committerMichael Stahl <mstahl@redhat.com>2015-03-10 00:15:17 +0100
commit666fb8b7bc210be6d785515bc7660e5a5d19b82e (patch)
tree35eab910c0d8e679e7b1ae8af41fb7eb2857f536 /i18npool
parent806ced87cfe3da72df0d8e4faf5b82535fc7d1b7 (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
Diffstat (limited to 'i18npool')
-rw-r--r--i18npool/source/search/textsearch.cxx21
1 files changed, 9 insertions, 12 deletions
diff --git a/i18npool/source/search/textsearch.cxx b/i18npool/source/search/textsearch.cxx
index 40dffc958721..8dda89df3eca 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));
}
}