[Libreoffice-commits] core.git: sc/source

Michael Meeks michael.meeks at collabora.com
Fri Apr 6 13:57:52 UTC 2018


 sc/source/core/data/table3.cxx |   52 +++++++++++++++++++++++++++++++----------
 1 file changed, 40 insertions(+), 12 deletions(-)

New commits:
commit 76bc1a81d089d9f66639c118c4063d87e4422684
Author: Michael Meeks <michael.meeks at 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 <ci at libreoffice.org>
    Reviewed-by: Eike Rathke <erack at 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:


More information about the Libreoffice-commits mailing list