diff --git a/include/o3tl/lru_map.hxx b/include/o3tl/lru_map.hxx index 64428d568f64..65268ea85b4d 100644 --- a/include/o3tl/lru_map.hxx +++ b/include/o3tl/lru_map.hxx @@ -205,7 +205,7 @@ public: checkLRUMaxSize(); } - list_const_iterator_t insert(key_value_pair_t& rPair) + void insert(key_value_pair_t& rPair) { map_iterator_t i = mLruMap.find(rPair.first); @@ -230,11 +230,9 @@ public: mLruList.splice(mLruList.begin(), mLruList, i->second); checkLRUItemUpdate(); } - - return mLruList.cbegin(); } - list_const_iterator_t insert(key_value_pair_t&& rPair) + void insert(key_value_pair_t&& rPair) { map_iterator_t i = mLruMap.find(rPair.first); @@ -258,8 +256,6 @@ public: mLruList.splice(mLruList.begin(), mLruList, i->second); checkLRUItemUpdate(); } - - return mLruList.cbegin(); } list_const_iterator_t find(const Key& key) @@ -305,12 +301,6 @@ public: return mLruMap.size(); } - size_t empty() const - { - assert(mLruMap.empty() == mLruList.empty()); - return mLruMap.empty(); - } - // size_t total_size() const; - only if custom ValueSize void clear() diff --git a/sc/inc/conditio.hxx b/sc/inc/conditio.hxx index 35252a185067..f38b81cc999e 100644 --- a/sc/inc/conditio.hxx +++ b/sc/inc/conditio.hxx @@ -34,8 +34,6 @@ #include #include #include -#include -#include #include #include @@ -303,7 +301,7 @@ public: } }; -class SAL_DLLPUBLIC_RTTI ScConditionEntry : public ScFormatEntry, public CacheOwner +class SAL_DLLPUBLIC_RTTI ScConditionEntry : public ScFormatEntry { // stored data: ScConditionMode eOp; @@ -325,9 +323,6 @@ class SAL_DLLPUBLIC_RTTI ScConditionEntry : public ScFormatEntry, public CacheOw OUString aSrcString; // formula source position as text during XML import std::unique_ptr pFCell1; std::unique_ptr pFCell2; - typedef o3tl::lru_map> RelRefCells; - std::unique_ptr xRelRefCells1; - std::unique_ptr xRelRefCells2; bool bRelRef1; bool bRelRef2; bool bFirstRun; @@ -351,8 +346,6 @@ class SAL_DLLPUBLIC_RTTI ScConditionEntry : public ScFormatEntry, public CacheOw bool IsValidStr( const OUString& rArg, const ScAddress& rPos ) const; void StartListening(); - static std::unique_ptr makeRelRefCells(); - public: ScConditionEntry( ScConditionMode eOper, const OUString& rExpr1, const OUString& rExpr2, @@ -408,10 +401,6 @@ public: virtual void UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt ) override; virtual void UpdateMoveTab( sc::RefUpdateMoveTabContext& rCxt ) override; - virtual bool dropCaches() override; - virtual void dumpState(rtl::OStringBuffer& rState) override; - virtual OUString getCacheName() const override; - bool MarkUsedExternalReferences() const; virtual Type GetType() const override { return eConditionType; } diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx index 17fcf17ccd89..9f5880dd51d0 100644 --- a/sc/source/core/data/conditio.cxx +++ b/sc/source/core/data/conditio.cxx @@ -458,9 +458,7 @@ void ScConditionEntry::SetCaseSensitive(bool bSet) void ScConditionEntry::CompileAll() { pFCell1.reset(); - xRelRefCells1.reset(); pFCell2.reset(); - xRelRefCells2.reset(); } void ScConditionEntry::CompileXML() @@ -555,11 +553,7 @@ void ScConditionEntry::UpdateReference( sc::RefUpdateContext& rCxt ) } if (aRes.mbReferenceModified || bChangedPos) - { - // is created again in IsValid - pFCell1.reset(); - xRelRefCells1.reset(); - } + pFCell1.reset(); // is created again in IsValid } if (pFormula2) @@ -578,11 +572,7 @@ void ScConditionEntry::UpdateReference( sc::RefUpdateContext& rCxt ) } if (aRes.mbReferenceModified || bChangedPos) - { - // is created again in IsValid - pFCell2.reset(); - xRelRefCells2.reset(); - } + pFCell2.reset(); // is created again in IsValid } StartListening(); @@ -594,14 +584,12 @@ void ScConditionEntry::UpdateInsertTab( sc::RefUpdateInsertTabContext& rCxt ) { pFormula1->AdjustReferenceOnInsertedTab(rCxt, aSrcPos); pFCell1.reset(); - xRelRefCells1.reset(); } if (pFormula2) { pFormula2->AdjustReferenceOnInsertedTab(rCxt, aSrcPos); pFCell2.reset(); - xRelRefCells2.reset(); } ScRangeUpdater::UpdateInsertTab(aSrcPos, rCxt); @@ -613,14 +601,12 @@ void ScConditionEntry::UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt ) { pFormula1->AdjustReferenceOnDeletedTab(rCxt, aSrcPos); pFCell1.reset(); - xRelRefCells1.reset(); } if (pFormula2) { pFormula2->AdjustReferenceOnDeletedTab(rCxt, aSrcPos); pFCell2.reset(); - xRelRefCells2.reset(); } ScRangeUpdater::UpdateDeleteTab(aSrcPos, rCxt); @@ -637,7 +623,6 @@ void ScConditionEntry::UpdateMoveTab(sc::RefUpdateMoveTabContext& rCxt) if (aRes.mbValueChanged) aResFinal.mnTab = aRes.mnTab; pFCell1.reset(); - xRelRefCells1.reset(); } if (pFormula2) @@ -646,7 +631,6 @@ void ScConditionEntry::UpdateMoveTab(sc::RefUpdateMoveTabContext& rCxt) if (aRes.mbValueChanged) aResFinal.mnTab = aRes.mnTab; pFCell2.reset(); - xRelRefCells2.reset(); } if (aResFinal.mnTab != aSrcPos.Tab()) @@ -693,12 +677,6 @@ bool ScConditionEntry::IsEqual( const ScFormatEntry& rOther, bool bIgnoreSrcPos return true; } -//static -std::unique_ptr ScConditionEntry::makeRelRefCells() -{ - return std::make_unique(0x9fff); -} - void ScConditionEntry::Interpret( const ScAddress& rPos ) { // Create formula cells @@ -709,25 +687,16 @@ void ScConditionEntry::Interpret( const ScAddress& rPos ) // Evaluate formulas bool bDirty = false; // 1 and 2 separate? + std::optional oTemp; ScFormulaCell* pEff1 = pFCell1.get(); if ( bRelRef1 ) { - if (!xRelRefCells1) - xRelRefCells1 = makeRelRefCells(); - auto iFind = xRelRefCells1->find(rPos); - if (iFind != xRelRefCells1->end()) - pEff1 = iFind->second.get(); + if (pFormula1) + oTemp.emplace(mrDoc, rPos, *pFormula1); else - { - std::unique_ptr xCell; - if (pFormula1) - xCell = std::make_unique(mrDoc, rPos, *pFormula1); - else - xCell = std::make_unique(mrDoc, rPos); - xCell->SetFreeFlying(true); - xCell->StartListeningTo(mrDoc); - pEff1 = xRelRefCells1->insert(std::make_pair(rPos, std::move(xCell)))->second.get(); - } + oTemp.emplace(mrDoc, rPos); + pEff1 = &*oTemp; + pEff1->SetFreeFlying(true); } if ( pEff1 ) { @@ -750,26 +719,17 @@ void ScConditionEntry::Interpret( const ScAddress& rPos ) } } } + oTemp.reset(); ScFormulaCell* pEff2 = pFCell2.get(); //@ 1!=2 if ( bRelRef2 ) { - if (!xRelRefCells2) - xRelRefCells2 = makeRelRefCells(); - auto iFind = xRelRefCells2->find(rPos); - if (iFind != xRelRefCells2->end()) - pEff2 = iFind->second.get(); + if (pFormula2) + oTemp.emplace(mrDoc, rPos, *pFormula2); else - { - std::unique_ptr xCell; - if (pFormula2) - xCell = std::make_unique(mrDoc, rPos, *pFormula2); - else - xCell = std::make_unique(mrDoc, rPos); - xCell->SetFreeFlying(true); - xCell->StartListeningTo(mrDoc); - pEff2 = xRelRefCells2->insert(std::make_pair(rPos, std::move(xCell)))->second.get(); - } + oTemp.emplace(mrDoc, rPos); + pEff2 = &*oTemp; + pEff2->SetFreeFlying(true); } if ( pEff2 ) { @@ -791,6 +751,7 @@ void ScConditionEntry::Interpret( const ScAddress& rPos ) } } } + oTemp.reset(); // If IsRunning, the last values remain if (bDirty && !bFirstRun) @@ -1605,47 +1566,16 @@ ScFormatEntry* ScCondFormatEntry::Clone( ScDocument& rDoc ) const void ScConditionEntry::CalcAll() { - if (pFCell1 || pFCell2 || xRelRefCells1 || !xRelRefCells2) + if (pFCell1 || pFCell2) { if (pFCell1) pFCell1->SetDirty(); - if (xRelRefCells1) - { - for (auto& rEntry : *xRelRefCells1) - rEntry.second->SetDirty(); - } if (pFCell2) pFCell2->SetDirty(); - if (xRelRefCells2) - { - for (auto& rEntry : *xRelRefCells2) - rEntry.second->SetDirty(); - } pCondFormat->DoRepaint(); } } -OUString ScConditionEntry::getCacheName() const -{ - return "ScConditionEntry"; -} - -bool ScConditionEntry::dropCaches() -{ - xRelRefCells1.reset(); - xRelRefCells2.reset(); - return true; -} - -void ScConditionEntry::dumpState(rtl::OStringBuffer& rState) -{ - rState.append("\nScConditionEntry:"); - rState.append("\n\t rel ref cells1: "); - rState.append(xRelRefCells1 ? static_cast(xRelRefCells1->size()) : 0); - rState.append("\n\t rel ref cells2: "); - rState.append(xRelRefCells2 ? static_cast(xRelRefCells2->size()) : 0); -} - ScCondDateFormatEntry::ScCondDateFormatEntry( ScDocument& rDoc ) : ScFormatEntry( rDoc ) , meType(condformat::TODAY)