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

New commits:
commit ed9eff7d91dcf7ffb87906422be61606e3117fae
Author:     Luboš Luňák <l.lu...@collabora.com>
AuthorDate: Tue Nov 23 19:09:43 2021 +0100
Commit:     Luboš Luňák <l.lu...@collabora.com>
CommitDate: Tue Nov 23 23:40:11 2021 +0100

    short-circut SC_AND lookup if left side is known to be false
    
    Change-Id: Ia1badb975f4effca668a5c2a41cfef3beccf8e2b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125739
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lu...@collabora.com>

diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 9c926fadf4fb..0fe6b10b0ba3 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -3043,6 +3043,18 @@ bool ScTable::ValidQuery(
     for (it = itBeg; it != itEnd && (*it)->bDoQuery; ++it)
     {
         const ScQueryEntry& rEntry = **it;
+
+        // Short-circuit the test at the end of the loop - if this is SC_AND
+        // and the previous value is false, this value will not be needed.
+        // Disbable this if pbTestEqualCondition is present as that one may 
get set
+        // even if the result is false (that also means pTest doesn't need to 
be
+        // handled here).
+        if (rEntry.eConnect == SC_AND && pbTestEqualCondition == nullptr
+             && nPos != -1 && !pPasst[nPos])
+        {
+            continue;
+        }
+
         SCCOL nCol = static_cast<SCCOL>(rEntry.nField);
 
         // We can only handle one single direct query passed as a known pCell,

Reply via email to