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

Tor Lillqvist tml at collabora.com
Thu Aug 3 14:39:43 UTC 2017


 sc/source/core/data/table3.cxx |   34 +++++++++++++++++++++-------------
 1 file changed, 21 insertions(+), 13 deletions(-)

New commits:
commit 59a00dde20b7862ad5e5e0f208631dae6c213bb5
Author: Tor Lillqvist <tml at collabora.com>
Date:   Wed Aug 2 21:33:42 2017 +0300

    Make this function multi-thread safe again
    
    This reverts commits 633178bffaf23ae322060e2c304c9c2cf12b46cc and
    e6ae91a8248fceee4248aadaf9f8aadec3fcc2bc.
    
    Alternatively the static aResults could have been made thread_local.
    
    Change-Id: I3b689c49ba3b7b2ee8ccdb8ec77a9c8cb6f306d1

diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index c42463ab9f20..cc1857cf9d33 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -2659,12 +2659,14 @@ bool ScTable::ValidQuery(
     if (!rParam.GetEntry(0).bDoQuery)
         return true;
 
-    SCSIZE nEntryCount = rParam.GetEntryCount();
+    //---------------------------------------------------------------
 
-    typedef std::pair<bool,bool> ResultType;
-    static std::vector<ResultType> aResults;
-    if (aResults.size() < nEntryCount)
-        aResults.resize(nEntryCount);
+    const SCSIZE nFixedBools = 32;
+    bool aBool[nFixedBools];
+    bool aTest[nFixedBools];
+    SCSIZE nEntryCount = rParam.GetEntryCount();
+    bool* pPasst = ( nEntryCount <= nFixedBools ? &aBool[0] : new bool[nEntryCount] );
+    bool* pTest = ( nEntryCount <= nFixedBools ? &aTest[0] : new bool[nEntryCount] );
 
     long    nPos = -1;
     QueryEvaluator aEval(*pDocument, *this, rParam, pbTestEqualCondition);
@@ -2727,32 +2729,38 @@ bool ScTable::ValidQuery(
         if (nPos == -1)
         {
             nPos++;
-            aResults[nPos] = aRes;
+            pPasst[nPos] = aRes.first;
+            pTest[nPos] = aRes.second;
         }
         else
         {
             if (rEntry.eConnect == SC_AND)
             {
-                aResults[nPos].first = aResults[nPos].first && aRes.first;
-                aResults[nPos].second = aResults[nPos].second && aRes.second;
+                pPasst[nPos] = pPasst[nPos] && aRes.first;
+                pTest[nPos] = pTest[nPos] && aRes.second;
             }
             else
             {
                 nPos++;
-                aResults[nPos] = aRes;
+                pPasst[nPos] = aRes.first;
+                pTest[nPos] = aRes.second;
             }
         }
     }
 
     for ( long j=1; j <= nPos; j++ )
     {
-        aResults[0].first = aResults[0].first || aResults[j].first;
-        aResults[0].second = aResults[0].second || aResults[j].second;
+        pPasst[0] = pPasst[0] || pPasst[j];
+        pTest[0] = pTest[0] || pTest[j];
     }
 
-    bool bRet = aResults[0].first;
+    bool bRet = pPasst[0];
+    if ( pPasst != &aBool[0] )
+        delete [] pPasst;
     if ( pbTestEqualCondition )
-        *pbTestEqualCondition = aResults[0].second;
+        *pbTestEqualCondition = pTest[0];
+    if ( pTest != &aTest[0] )
+        delete [] pTest;
 
     return bRet;
 }


More information about the Libreoffice-commits mailing list