diff options
-rw-r--r-- | sc/inc/column.hxx | 2 | ||||
-rw-r--r-- | sc/inc/document.hxx | 2 | ||||
-rw-r--r-- | sc/inc/formulacell.hxx | 2 | ||||
-rw-r--r-- | sc/inc/table.hxx | 2 | ||||
-rw-r--r-- | sc/source/core/data/column2.cxx | 4 | ||||
-rw-r--r-- | sc/source/core/data/documen8.cxx | 4 | ||||
-rw-r--r-- | sc/source/core/data/formulacell.cxx | 17 | ||||
-rw-r--r-- | sc/source/core/data/table1.cxx | 5 |
8 files changed, 24 insertions, 14 deletions
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx index 3b7ffbe645e1..18cf3de6231f 100644 --- a/sc/inc/column.hxx +++ b/sc/inc/column.hxx @@ -595,7 +595,7 @@ public: void CalculateInThread( ScInterpreterContext& rContext, SCROW nRow, size_t nLen, size_t nOffset, unsigned nThisThread, unsigned nThreadsTotal ); - void HandleStuffAfterParallelCalculation( SCROW nRow, size_t nLen ); + void HandleStuffAfterParallelCalculation( SCROW nRow, size_t nLen, ScInterpreter* pInterpreter ); void SetNumberFormat( SCROW nRow, sal_uInt32 nNumberFormat ); diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 9e19ad228a36..256f105ed7fd 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -2153,7 +2153,7 @@ public: void SC_DLLPUBLIC SetFormulaResults( const ScAddress& rTopPos, const double* pResults, size_t nLen ); const ScDocumentThreadSpecific& CalculateInColumnInThread( ScInterpreterContext& rContext, const ScRange& rCalcRange, unsigned nThisThread, unsigned nThreadsTotal); - void HandleStuffAfterParallelCalculation( SCCOL nColStart, SCCOL nColEnd, SCROW nRow, size_t nLen, SCTAB nTab ); + void HandleStuffAfterParallelCalculation( SCCOL nColStart, SCCOL nColEnd, SCROW nRow, size_t nLen, SCTAB nTab, ScInterpreter* pInterpreter ); /** * Transfer a series of contiguous cell values from specified position to diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx index 65a3a4af7733..9a5af01a3851 100644 --- a/sc/inc/formulacell.hxx +++ b/sc/inc/formulacell.hxx @@ -167,7 +167,7 @@ public: }; void InterpretTail( ScInterpreterContext&, ScInterpretTailParameter ); - void HandleStuffAfterParallelCalculation(); + void HandleStuffAfterParallelCalculation(ScInterpreter* pInterpreter); enum CompareState { NotEqual = 0, EqualInvariant, EqualRelativeRef }; diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx index 78bfa854e33d..9756930b08e1 100644 --- a/sc/inc/table.hxx +++ b/sc/inc/table.hxx @@ -1014,7 +1014,7 @@ public: void CalculateInColumnInThread( ScInterpreterContext& rContext, SCCOL nColStart, SCCOL nColEnd, SCROW nRowStart, SCROW nRowEnd, unsigned nThisThread, unsigned nThreadsTotal); - void HandleStuffAfterParallelCalculation( SCCOL nColStart, SCCOL nColEnd, SCROW nRow, size_t nLen); + void HandleStuffAfterParallelCalculation( SCCOL nColStart, SCCOL nColEnd, SCROW nRow, size_t nLen, ScInterpreter* pInterpreter); /** * Either start all formula cells as listeners unconditionally, or start diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx index c0fcc103b676..5e62a01f38a1 100644 --- a/sc/source/core/data/column2.cxx +++ b/sc/source/core/data/column2.cxx @@ -2966,7 +2966,7 @@ void ScColumn::CalculateInThread( ScInterpreterContext& rContext, SCROW nRow, si } } -void ScColumn::HandleStuffAfterParallelCalculation( SCROW nRow, size_t nLen ) +void ScColumn::HandleStuffAfterParallelCalculation( SCROW nRow, size_t nLen, ScInterpreter* pInterpreter ) { sc::CellStoreType::position_type aPos = maCells.position(nRow); sc::CellStoreType::iterator it = aPos.first; @@ -2988,7 +2988,7 @@ void ScColumn::HandleStuffAfterParallelCalculation( SCROW nRow, size_t nLen ) for (size_t i = 0; i < nLen; ++i, ++itCell) { ScFormulaCell& rCell = **itCell; - rCell.HandleStuffAfterParallelCalculation(); + rCell.HandleStuffAfterParallelCalculation(pInterpreter); } } diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx index 5068656aab39..787d0d7fed85 100644 --- a/sc/source/core/data/documen8.cxx +++ b/sc/source/core/data/documen8.cxx @@ -428,7 +428,7 @@ const ScDocumentThreadSpecific& ScDocument::CalculateInColumnInThread( ScInterpr return maThreadSpecific; } -void ScDocument::HandleStuffAfterParallelCalculation( SCCOL nColStart, SCCOL nColEnd, SCROW nRow, size_t nLen, SCTAB nTab ) +void ScDocument::HandleStuffAfterParallelCalculation( SCCOL nColStart, SCCOL nColEnd, SCROW nRow, size_t nLen, SCTAB nTab, ScInterpreter* pInterpreter ) { assert(!IsThreadedGroupCalcInProgress()); for( const DelayedSetNumberFormat& data : GetNonThreadedContext().maDelayedSetNumberFormat) @@ -439,7 +439,7 @@ void ScDocument::HandleStuffAfterParallelCalculation( SCCOL nColStart, SCCOL nCo if (!pTab) return; - pTab->HandleStuffAfterParallelCalculation(nColStart, nColEnd, nRow, nLen); + pTab->HandleStuffAfterParallelCalculation(nColStart, nColEnd, nRow, nLen, pInterpreter); } void ScDocument::InvalidateTextWidth( const ScAddress* pAdrFrom, const ScAddress* pAdrTo, diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx index d3dfbd18ea1a..9eb36602d319 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -2298,14 +2298,21 @@ void ScFormulaCell::InterpretTail( ScInterpreterContext& rContext, ScInterpretTa } } -void ScFormulaCell::HandleStuffAfterParallelCalculation() +void ScFormulaCell::HandleStuffAfterParallelCalculation(ScInterpreter* pInterpreter) { if( pCode->GetCodeLen() && pDocument ) { if ( !pCode->IsRecalcModeAlways() ) pDocument->RemoveFromFormulaTree( this ); - std::unique_ptr<ScInterpreter> pInterpreter(new ScInterpreter( this, pDocument, pDocument->GetNonThreadedContext(), aPos, *pCode )); + std::unique_ptr<ScInterpreter> pScopedInterpreter; + if (pInterpreter) + pInterpreter->Init(this, aPos, *pCode); + else + { + pScopedInterpreter.reset(new ScInterpreter( this, pDocument, pDocument->GetNonThreadedContext(), aPos, *pCode )); + pInterpreter = pScopedInterpreter.get(); + } switch (pInterpreter->GetVolatileType()) { @@ -4843,6 +4850,7 @@ bool ScFormulaCell::InterpretFormulaGroupThreading(sc::FormulaLogger::GroupScope } } + std::vector<std::unique_ptr<ScInterpreter>> aInterpreters(nThreadCount); { assert(!pDocument->IsThreadedGroupCalcInProgress()); pDocument->SetThreadedGroupCalcInProgress(true); @@ -4853,7 +4861,6 @@ bool ScFormulaCell::InterpretFormulaGroupThreading(sc::FormulaLogger::GroupScope std::shared_ptr<comphelper::ThreadTaskTag> aTag = comphelper::ThreadPool::createThreadTaskTag(); ScThreadedInterpreterContextGetterGuard aContextGetterGuard(nThreadCount, *pDocument, pNonThreadedFormatter); ScInterpreterContext* context = nullptr; - std::vector<std::unique_ptr<ScInterpreter>> aInterpreters(nThreadCount); for (int i = 0; i < nThreadCount; ++i) { @@ -4887,7 +4894,9 @@ bool ScFormulaCell::InterpretFormulaGroupThreading(sc::FormulaLogger::GroupScope ScAddress aStartPos(mxGroup->mpTopCell->aPos); SCROW nSpanLen = nEndOffset - nStartOffset + 1; aStartPos.SetRow(aStartPos.Row() + nStartOffset); - pDocument->HandleStuffAfterParallelCalculation(nColStart, nColEnd, aStartPos.Row(), nSpanLen, aStartPos.Tab()); + // Reuse one of the previously allocated interpreter objects here. + pDocument->HandleStuffAfterParallelCalculation(nColStart, nColEnd, aStartPos.Row(), nSpanLen, + aStartPos.Tab(), aInterpreters[0].get()); return true; } diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx index 69e0d7ac9713..84c4210775c4 100644 --- a/sc/source/core/data/table1.cxx +++ b/sc/source/core/data/table1.cxx @@ -2485,12 +2485,13 @@ void ScTable::CalculateInColumnInThread( ScInterpreterContext& rContext, } } -void ScTable::HandleStuffAfterParallelCalculation( SCCOL nColStart, SCCOL nColEnd, SCROW nRow, size_t nLen) +void ScTable::HandleStuffAfterParallelCalculation( SCCOL nColStart, SCCOL nColEnd, SCROW nRow, size_t nLen, + ScInterpreter* pInterpreter) { assert(ValidCol(nColStart) && ValidCol(nColEnd)); for (SCCOL nCurrCol = nColStart; nCurrCol <= nColEnd; ++nCurrCol) - aCol[nCurrCol].HandleStuffAfterParallelCalculation( nRow, nLen ); + aCol[nCurrCol].HandleStuffAfterParallelCalculation( nRow, nLen, pInterpreter ); } #if DUMP_COLUMN_STORAGE |