sc/source/core/data/table3.cxx | 52 +++++++++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 12 deletions(-)
New commits: commit 76bc1a81d089d9f66639c118c4063d87e4422684 Author: Michael Meeks <michael.me...@collabora.com> Date: Thu Apr 5 16:15:32 2018 +0100 tdf#115490 - avoid transliteration by using SharedString. Do this only for case insensitive matching for now; optimizing vlookup nicely - for me saves 35% of the compute time for 10k rows. Change-Id: I9b212910baa9d1b58e846e8e687bb10ab6106558 Reviewed-on: https://gerrit.libreoffice.org/51159 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Eike Rathke <er...@redhat.com> diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx index 6e69e2b35d5a..91a47bb4c17f 100644 --- a/sc/source/core/data/table3.cxx +++ b/sc/source/core/data/table3.cxx @@ -2257,6 +2257,7 @@ class QueryEvaluator utl::TransliterationWrapper* mpTransliteration; CollatorWrapper* mpCollator; const bool mbMatchWholeCell; + const bool mbCaseSensitive; static bool isPartialTextMatchOp(const ScQueryEntry& rEntry) { @@ -2320,7 +2321,8 @@ public: mrTab(rTab), mrParam(rParam), mpTestEqualCondition(pTestEqualCondition), - mbMatchWholeCell(rDoc.GetDocOptions().IsMatchWholeCell()) + mbMatchWholeCell(rDoc.GetDocOptions().IsMatchWholeCell()), + mbCaseSensitive( rParam.bCaseSens ) { if (rParam.bCaseSens) { @@ -2583,19 +2585,45 @@ public: // Where do we find a match (if at all) sal_Int32 nStrPos; - OUString aQueryStr = rItem.maString.getString(); - const LanguageType nLang = ScGlobal::pSysLocale->GetLanguageTag().getLanguageType(); - OUString aCell( mpTransliteration->transliterate( - aCellStr.getString(), nLang, 0, aCellStr.getLength(), - nullptr ) ); + if (!mbCaseSensitive) + { // Common case for vlookup etc. + const rtl_uString *pQuer = rItem.maString.getDataIgnoreCase(); + const rtl_uString *pCellStr = aCellStr.getDataIgnoreCase(); + assert(pQuer != nullptr); + assert(pCellStr != nullptr); - OUString aQuer( mpTransliteration->transliterate( - aQueryStr, nLang, 0, aQueryStr.getLength(), - nullptr ) ); + sal_Int32 nIndex = (rEntry.eOp == SC_ENDS_WITH || + rEntry.eOp == SC_DOES_NOT_END_WITH) ? + (pCellStr->length - pQuer->length) : 0; - sal_Int32 nIndex = (rEntry.eOp == SC_ENDS_WITH || rEntry.eOp == SC_DOES_NOT_END_WITH) ? - (aCell.getLength() - aQuer.getLength()) : 0; - nStrPos = ((nIndex < 0) ? -1 : aCell.indexOf( aQuer, nIndex )); + if (nIndex < 0) + nStrPos = -1; + else + { // OUString::indexOf + nStrPos = rtl_ustr_indexOfStr_WithLength( + pCellStr->buffer + nIndex, pCellStr->length - nIndex, + pQuer->buffer, pQuer->length ); + + if (nStrPos >= 0) + nStrPos += nIndex; + } + } + else + { + OUString aQueryStr = rItem.maString.getString(); + const LanguageType nLang = ScGlobal::pSysLocale->GetLanguageTag().getLanguageType(); + OUString aCell( mpTransliteration->transliterate( + aCellStr.getString(), nLang, 0, aCellStr.getLength(), + nullptr ) ); + + OUString aQuer( mpTransliteration->transliterate( + aQueryStr, nLang, 0, aQueryStr.getLength(), + nullptr ) ); + + sal_Int32 nIndex = (rEntry.eOp == SC_ENDS_WITH || rEntry.eOp == SC_DOES_NOT_END_WITH) ? + (aCell.getLength() - aQuer.getLength()) : 0; + nStrPos = ((nIndex < 0) ? -1 : aCell.indexOf( aQuer, nIndex )); + } switch (rEntry.eOp) { case SC_EQUAL: _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits