sc/inc/queryevaluator.hxx              |    6 +--
 sc/source/core/data/queryevaluator.cxx |   53 +++++++++------------------------
 2 files changed, 18 insertions(+), 41 deletions(-)

New commits:
commit d0ec8bc47a3e605667a3c6887feb4157e488f96b
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Fri Oct 25 11:08:44 2024 +0100
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Fri Oct 25 17:00:42 2024 +0200

    ScQueryEvaluator::compareByString now never has non-null pValueSource2
    
    and always has non-null pValueSource1
    
    Change-Id: I5774e8beefeb5e40d316ea8557c656a126f4a7ec
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175637
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/sc/inc/queryevaluator.hxx b/sc/inc/queryevaluator.hxx
index a2cbc0848a3b..f5817820d4fe 100644
--- a/sc/inc/queryevaluator.hxx
+++ b/sc/inc/queryevaluator.hxx
@@ -91,9 +91,9 @@ class ScQueryEvaluator
 
     bool isFastCompareByString(const ScQueryEntry& rEntry) const;
     template <bool bFast = false>
-    std::pair<bool, bool>
-    compareByString(const ScQueryEntry& rEntry, const ScQueryEntry::Item& 
rItem,
-                    const svl::SharedString* pValueSource1, const OUString* 
pValueSource2);
+    std::pair<bool, bool> compareByString(const ScQueryEntry& rEntry,
+                                          const ScQueryEntry::Item& rItem,
+                                          const svl::SharedString* 
pValueSource1);
     std::pair<bool, bool> compareByTextColor(SCCOL nCol, SCROW nRow,
                                              const ScQueryEntry::Item& rItem);
     std::pair<bool, bool> compareByBackgroundColor(SCCOL nCol, SCROW nRow,
diff --git a/sc/source/core/data/queryevaluator.cxx 
b/sc/source/core/data/queryevaluator.cxx
index 17f500ffc629..89d2d38d2bd4 100644
--- a/sc/source/core/data/queryevaluator.cxx
+++ b/sc/source/core/data/queryevaluator.cxx
@@ -370,13 +370,12 @@ bool ScQueryEvaluator::isFastCompareByString(const 
ScQueryEntry& rEntry) const
            && isMatchWholeCell(rEntry.eOp);
 }
 
-// The value is placed inside one parameter: [pValueSource1] or 
[pValueSource2] but never in both.
+// The value is placed inside one parameter: [pValueSource1].
 // For the template argument see isFastCompareByString().
 template <bool bFast>
 std::pair<bool, bool> ScQueryEvaluator::compareByString(const ScQueryEntry& 
rEntry,
                                                         const 
ScQueryEntry::Item& rItem,
-                                                        const 
svl::SharedString* pValueSource1,
-                                                        const OUString* 
pValueSource2)
+                                                        const 
svl::SharedString* pValueSource1)
 {
     bool bOk = false;
     bool bTestEqual = false;
@@ -388,13 +387,11 @@ std::pair<bool, bool> 
ScQueryEvaluator::compareByString(const ScQueryEntry& rEnt
     const bool bRealWildOrRegExp = !bFast && isRealWildOrRegExp(rEntry);
     const bool bTestWildOrRegExp = !bFast && isTestWildOrRegExp(rEntry);
 
-    assert(!bFast || pValueSource1 != nullptr); // shared string for fast path
-    // [pValueSource1] or [pValueSource2] but never both of them or none of 
them
-    assert((pValueSource1 != nullptr) != (pValueSource2 != nullptr));
+    assert(pValueSource1);
 
     if (!bFast && (bRealWildOrRegExp || bTestWildOrRegExp))
     {
-        const OUString& rValue = pValueSource1 ? pValueSource1->getString() : 
*pValueSource2;
+        const OUString& rValue = pValueSource1->getString();
 
         sal_Int32 nStart = 0;
         sal_Int32 nEnd = rValue.getLength();
@@ -466,33 +463,15 @@ std::pair<bool, bool> 
ScQueryEvaluator::compareByString(const ScQueryEntry& rEnt
             }
             else if (bFast || bMatchWholeCell)
             {
-                if (bFast || pValueSource1)
+                // Fast string equality check by comparing string identifiers.
+                // This is the bFast path, all conditions should lead here on 
bFast == true.
+                if (mrParam.bCaseSens)
                 {
-                    // Fast string equality check by comparing string 
identifiers.
-                    // This is the bFast path, all conditions should lead here 
on bFast == true.
-                    if (mrParam.bCaseSens)
-                    {
-                        bOk = pValueSource1->getData() == 
rItem.maString.getData();
-                    }
-                    else
-                    {
-                        bOk = pValueSource1->getDataIgnoreCase()
-                              == rItem.maString.getDataIgnoreCase();
-                    }
+                    bOk = pValueSource1->getData() == rItem.maString.getData();
                 }
-                else // if (pValueSource2)
+                else
                 {
-                    if (mrParam.bCaseSens)
-                    {
-                        bOk = (*pValueSource2 == rItem.maString.getString());
-                    }
-                    else
-                    {
-                        // fallback
-                        const svl::SharedString 
rSource2(mrStrPool.intern(*pValueSource2));
-                        // Fast string equality check by comparing string 
identifiers.
-                        bOk = rSource2.getDataIgnoreCase() == 
rItem.maString.getDataIgnoreCase();
-                    }
+                    bOk = pValueSource1->getDataIgnoreCase() == 
rItem.maString.getDataIgnoreCase();
                 }
 
                 if (!bFast && rEntry.eOp == SC_NOT_EQUAL)
@@ -505,8 +484,7 @@ std::pair<bool, bool> 
ScQueryEvaluator::compareByString(const ScQueryEntry& rEnt
 
                 if (!mbCaseSensitive)
                 { // Common case for vlookup etc.
-                    const svl::SharedString rSource(
-                        pValueSource1 ? *pValueSource1 : 
mrStrPool.intern(*pValueSource2));
+                    const svl::SharedString rSource(*pValueSource1);
 
                     const rtl_uString* pQuer = 
rItem.maString.getDataIgnoreCase();
                     const rtl_uString* pCellStr = rSource.getDataIgnoreCase();
@@ -534,8 +512,7 @@ std::pair<bool, bool> 
ScQueryEvaluator::compareByString(const ScQueryEntry& rEnt
                 }
                 else
                 {
-                    const OUString& rValue
-                        = pValueSource1 ? pValueSource1->getString() : 
*pValueSource2;
+                    const OUString& rValue = pValueSource1->getString();
                     const OUString aQueryStr = rItem.maString.getString();
                     const LanguageType nLang
                         = 
ScGlobal::oSysLocale->GetLanguageTag().getLanguageType();
@@ -582,7 +559,7 @@ std::pair<bool, bool> 
ScQueryEvaluator::compareByString(const ScQueryEntry& rEnt
         }
         else
         { // use collator here because data was probably sorted
-            const OUString& rValue = pValueSource1 ? 
pValueSource1->getString() : *pValueSource2;
+            const OUString& rValue = pValueSource1->getString();
             setupCollatorIfNeeded();
             sal_Int32 nCompare = mpCollator->compareString(rValue, 
rItem.maString.getString());
             switch (rEntry.eOp)
@@ -817,9 +794,9 @@ std::pair<bool, bool> ScQueryEvaluator::processEntry(SCROW 
nRow, SCCOL nCol, ScR
             svl::SharedString cellSharedString = getCellSharedString(aCell, 
nRow, rEntry.nField);
             std::pair<bool, bool> aThisRes;
             if (bFastCompareByString) // fast
-                aThisRes = compareByString<true>(rEntry, rItem, 
&cellSharedString, nullptr);
+                aThisRes = compareByString<true>(rEntry, rItem, 
&cellSharedString);
             else
-                aThisRes = compareByString(rEntry, rItem, &cellSharedString, 
nullptr);
+                aThisRes = compareByString(rEntry, rItem, &cellSharedString);
             aRes.first |= aThisRes.first;
             aRes.second |= aThisRes.second;
         }

Reply via email to