diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2018-04-05 16:15:32 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2018-04-06 15:57:29 +0200 |
commit | 76bc1a81d089d9f66639c118c4063d87e4422684 (patch) | |
tree | a520d48d7cfcbf425bdcc32c5be7a3aa8d5a359e | |
parent | 009a326d78fb62a80f9631844af324d0294710b6 (diff) |
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 <ci@libreoffice.org>
Reviewed-by: Eike Rathke <erack@redhat.com>
-rw-r--r-- | sc/source/core/data/table3.cxx | 52 |
1 files changed, 40 insertions, 12 deletions
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: |