Commit a2782fac authored by Milian Wolff's avatar Milian Wolff
Browse files

Distinguish between read/write ops to item repository

Basically replace the single ::op call with two variants:

1. read, taking a `const& repo`
2. write, taking a `& repo`

This clarifies the intention and makes the code more resilient.
While doing this change, I reviewed the usages and fix a few
cases where we took a mutable repo but only want/need a const ref.

Thanks to Igor Kushnir for the suggestion!
parent f72ca464
......@@ -208,7 +208,7 @@ void CodeModel::addItem(const IndexedString& file, const IndexedQualifiedIdentif
newItem.kind = kind;
newItem.referenceCount = 1;
LockedItemRepository::op<CodeModel>([&](CodeModelRepo& repo) {
LockedItemRepository::write<CodeModel>([&](CodeModelRepo& repo) {
uint index = repo.findIndex(item);
if (index) {
......@@ -275,7 +275,7 @@ void CodeModel::updateItem(const IndexedString& file, const IndexedQualifiedIden
newItem.kind = kind;
newItem.referenceCount = 1;
LockedItemRepository::op<CodeModel>([&](CodeModelRepo& repo) {
LockedItemRepository::write<CodeModel>([&](CodeModelRepo& repo) {
uint index = repo.findIndex(item);
if (index) {
......@@ -309,7 +309,7 @@ void CodeModel::removeItem(const IndexedString& file, const IndexedQualifiedIden
item.file = file;
CodeModelRequestItem request(item);
LockedItemRepository::op<CodeModel>([&](CodeModelRepo& repo) {
LockedItemRepository::write<CodeModel>([&](CodeModelRepo& repo) {
uint index = repo.findIndex(item);
if (index) {
......@@ -368,7 +368,7 @@ void CodeModel::items(const IndexedString& file, uint& count, const CodeModelIte
item.file = file;
CodeModelRequestItem request(item);
LockedItemRepository::op<CodeModel>([&](CodeModelRepo& repo) {
LockedItemRepository::read<CodeModel>([&](const CodeModelRepo& repo) {
uint index = repo.findIndex(item);
if (index) {
......
......@@ -179,7 +179,7 @@ QByteArray Declaration::comment() const
if (!d->m_comment)
return QByteArray();
return LockedItemRepository::op<DeclarationComment>([d](const Repositories::StringRepository& repo) {
return LockedItemRepository::read<DeclarationComment>([d](const Repositories::StringRepository& repo) {
return Repositories::arrayFromItem(repo.itemFromIndex(d->m_comment));
});
}
......@@ -195,7 +195,7 @@ void Declaration::setComment(const QByteArray& str)
const auto request = Repositories::StringRepositoryItemRequest(
str.constData(), IndexedString::hashString(str.constData(), str.length()), str.length());
d->m_comment = LockedItemRepository::op<DeclarationComment>(
d->m_comment = LockedItemRepository::write<DeclarationComment>(
[&](Repositories::StringRepository& repo) { return repo.index(request); });
}
......
......@@ -183,7 +183,7 @@ void Definitions::addDefinition(const DeclarationId& id, const IndexedDeclaratio
item.definitionsList().append(definition);
DefinitionsRequestItem request(item);
LockedItemRepository::op<DefinitionsItem>([&](DefinitionsRepo& repo) {
LockedItemRepository::write<DefinitionsItem>([&](DefinitionsRepo& repo) {
uint index = repo.findIndex(item);
if (index) {
......@@ -209,7 +209,7 @@ void Definitions::removeDefinition(const DeclarationId& id, const IndexedDeclara
item.declaration = id;
DefinitionsRequestItem request(item);
LockedItemRepository::op<DefinitionsItem>([&](DefinitionsRepo& repo) {
LockedItemRepository::write<DefinitionsItem>([&](DefinitionsRepo& repo) {
uint index = repo.findIndex(item);
if (index) {
......@@ -237,7 +237,7 @@ KDevVarLengthArray<IndexedDeclaration> Definitions::definitions(const Declaratio
item.declaration = id;
DefinitionsRequestItem request(item);
LockedItemRepository::op<DefinitionsItem>([&](const DefinitionsRepo& repo) {
LockedItemRepository::read<DefinitionsItem>([&](const DefinitionsRepo& repo) {
uint index = repo.findIndex(item);
if (index) {
......@@ -253,6 +253,6 @@ KDevVarLengthArray<IndexedDeclaration> Definitions::definitions(const Declaratio
void Definitions::dump(const QTextStream& out)
{
DefinitionsVisitor v(this, out);
LockedItemRepository::op<DefinitionsItem>([&](const DefinitionsRepo& repo) { repo.visitAllItems(v); });
LockedItemRepository::read<DefinitionsItem>([&](const DefinitionsRepo& repo) { repo.visitAllItems(v); });
}
}
......@@ -524,8 +524,9 @@ public:
void addEnvironmentInformation(ParsingEnvironmentFilePointer info)
{
Q_ASSERT(!findInformation(info->indexedTopContext().index()));
Q_ASSERT(LockedItemRepository::op<EnvironmentInformationItem>(
[&](EnvironmentInformationRepo& repo) { return repo.findIndex(info->indexedTopContext().index()) == 0; }));
Q_ASSERT(LockedItemRepository::read<EnvironmentInformationItem>([&](const EnvironmentInformationRepo& repo) {
return repo.findIndex(info->indexedTopContext().index()) == 0;
}));
QMutexLocker lock(&m_chainsMutex);
m_fileEnvironmentInformations.insert(info->url(), info);
......@@ -549,7 +550,7 @@ public:
removed2 = m_indexEnvironmentInformations.remove(info->indexedTopContext().index());
}
LockedItemRepository::op<EnvironmentInformationListItem>([&info](EnvironmentInformationListRepo& repo) {
LockedItemRepository::write<EnvironmentInformationListItem>([&info](EnvironmentInformationListRepo& repo) {
//Remove it from the environment information lists if it was there
uint index = repo.findIndex(info->url());
......@@ -563,7 +564,7 @@ public:
}
});
LockedItemRepository::op<EnvironmentInformationItem>(
LockedItemRepository::write<EnvironmentInformationItem>(
[&info, removed, removed2](EnvironmentInformationRepo& repo) {
uint index = repo.findIndex(info->indexedTopContext().index());
if (index) {
......@@ -587,8 +588,8 @@ public:
KDevVarLengthArray<uint> topContextIndices;
// First store all the possible indices into the KDevVarLengthArray, so we can process them without holding
// a mutex locked
LockedItemRepository::op<EnvironmentInformationListItem>(
[&topContextIndices, &url](EnvironmentInformationListRepo& repo) {
LockedItemRepository::read<EnvironmentInformationListItem>(
[&topContextIndices, &url](const EnvironmentInformationListRepo& repo) {
const EnvironmentInformationListItem* item = repo.findItem(url);
if (item) {
FOREACH_FUNCTION(uint topContextIndex, item->items)
......@@ -710,7 +711,7 @@ public:
for (const ParsingEnvironmentFilePointer& file : qAsConst(check)) {
EnvironmentInformationRequest req(file.data());
LockedItemRepository::op<EnvironmentInformationItem>([&](EnvironmentInformationRepo& repo) {
LockedItemRepository::write<EnvironmentInformationItem>([&](EnvironmentInformationRepo& repo) {
uint index = repo.findIndex(req);
if (file->d_func()->isDynamic()) {
......@@ -752,10 +753,10 @@ public:
storeInformationList(url);
//Access the data in the repository, so the bucket isn't unloaded
const auto foundItem
= LockedItemRepository::op<EnvironmentInformationListItem>([&](EnvironmentInformationListRepo& repo) {
return static_cast<bool>(repo.findItem(EnvironmentInformationListRequest(url)));
});
const auto foundItem = LockedItemRepository::read<EnvironmentInformationListItem>(
[&](const EnvironmentInformationListRepo& repo) {
return static_cast<bool>(repo.findItem(EnvironmentInformationListRequest(url)));
});
if (!foundItem) {
QMutexLocker chainLock(&m_chainsMutex);
qCDebug(LANGUAGE) << "Did not find stored item for" << url.str()
......@@ -1038,8 +1039,8 @@ unloadContexts:
// Step two: Check if it is on disk, and if is, load it
// TODO: this looks pretty dubious, shouldn't we keep the repo locked while operating on the item?
const auto item = LockedItemRepository::op<EnvironmentInformationItem>(
[req = EnvironmentInformationRequest(topContextIndex)](EnvironmentInformationRepo& repo) {
const auto item = LockedItemRepository::read<EnvironmentInformationItem>(
[req = EnvironmentInformationRequest(topContextIndex)](const EnvironmentInformationRepo& repo) {
return repo.findItem(req);
});
if (!item) {
......@@ -1088,7 +1089,7 @@ unloadContexts:
qCDebug(LANGUAGE) << "cleaning top-contexts";
CleanupListVisitor visitor;
uint startPos = 0;
LockedItemRepository::op<EnvironmentInformationItem>(
LockedItemRepository::write<EnvironmentInformationItem>(
[&visitor](EnvironmentInformationRepo& repo) { repo.visitAllItems(visitor); });
int checkContextsCount = maxFinalCleanupCheckContexts;
......@@ -1186,7 +1187,7 @@ private:
}
}
LockedItemRepository::op<EnvironmentInformationListItem>([&](EnvironmentInformationListRepo& repo) {
LockedItemRepository::write<EnvironmentInformationListItem>([&](EnvironmentInformationListRepo& repo) {
uint index = repo.findIndex(url);
if (index) {
......
......@@ -168,7 +168,7 @@ public:
static uint emptyConstantIdentifierPrivateIndex()
{
static const uint index = LockedItemRepository::op<IndexedIdentifier>(
static const uint index = LockedItemRepository::write<IndexedIdentifier>(
[](IdentifierRepository& repo) { return repo.index(DynamicIdentifierPrivate()); });
return index;
}
......@@ -348,7 +348,7 @@ class ItemRepositoryFor<IndexedQualifiedIdentifier>
static uint emptyConstantQualifiedIdentifierPrivateIndex()
{
static const uint index = LockedItemRepository::op<IndexedQualifiedIdentifier>(
static const uint index = LockedItemRepository::write<IndexedQualifiedIdentifier>(
[](QualifiedIdentifierRepository& repo) { return repo.index(DynamicQualifiedIdentifierPrivate()); });
return index;
}
......@@ -370,8 +370,8 @@ Identifier::Identifier(uint index)
: m_index(index)
{
Q_ASSERT(m_index);
cd = LockedItemRepository::op<IndexedIdentifier>(
[index](IdentifierRepository& repo) { return repo.itemFromIndex(index); });
cd = LockedItemRepository::read<IndexedIdentifier>(
[index](const IdentifierRepository& repo) { return repo.itemFromIndex(index); });
}
Identifier::Identifier(const IndexedString& str)
......@@ -637,7 +637,7 @@ void Identifier::makeConstant() const
if (m_index)
return;
LockedItemRepository::op<IndexedIdentifier>([&](IdentifierRepository& repo) {
LockedItemRepository::write<IndexedIdentifier>([&](IdentifierRepository& repo) {
m_index = repo.index(IdentifierItemRequest(*dd));
delete dd;
cd = repo.itemFromIndex(m_index);
......@@ -664,15 +664,15 @@ bool QualifiedIdentifier::inRepository() const
if (m_index)
return true;
return LockedItemRepository::op<IndexedQualifiedIdentifier>([&](QualifiedIdentifierRepository& repo) {
return LockedItemRepository::read<IndexedQualifiedIdentifier>([&](const QualifiedIdentifierRepository& repo) {
return static_cast<bool>(repo.findIndex(QualifiedIdentifierItemRequest(*dd)));
});
}
QualifiedIdentifier::QualifiedIdentifier(uint index)
: m_index(index)
, cd(LockedItemRepository::op<IndexedQualifiedIdentifier>(
[index](QualifiedIdentifierRepository& repo) { return repo.itemFromIndex(index); }))
, cd(LockedItemRepository::read<IndexedQualifiedIdentifier>(
[index](const QualifiedIdentifierRepository& repo) { return repo.itemFromIndex(index); }))
{
}
......@@ -1140,7 +1140,7 @@ void QualifiedIdentifier::makeConstant() const
if (m_index)
return;
LockedItemRepository::op<IndexedQualifiedIdentifier>([&](QualifiedIdentifierRepository& repo) {
LockedItemRepository::write<IndexedQualifiedIdentifier>([&](QualifiedIdentifierRepository& repo) {
m_index = repo.index(QualifiedIdentifierItemRequest(*dd));
delete dd;
cd = repo.itemFromIndex(m_index);
......
......@@ -139,7 +139,7 @@ void Importers::addImporter(const DeclarationId& id, const IndexedDUContext& use
item.importersList().append(use);
ImportersRequestItem request(item);
LockedItemRepository::op<ImportersItem>([&](ImportersRepo& repo) {
LockedItemRepository::write<ImportersItem>([&](ImportersRepo& repo) {
uint index = repo.findIndex(item);
if (index) {
......@@ -165,7 +165,7 @@ void Importers::removeImporter(const DeclarationId& id, const IndexedDUContext&
item.declaration = id;
ImportersRequestItem request(item);
LockedItemRepository::op<ImportersItem>([&](ImportersRepo& repo) {
LockedItemRepository::write<ImportersItem>([&](ImportersRepo& repo) {
uint index = repo.findIndex(item);
if (index) {
......@@ -193,7 +193,7 @@ KDevVarLengthArray<IndexedDUContext> Importers::importers(const DeclarationId& i
item.declaration = id;
ImportersRequestItem request(item);
LockedItemRepository::op<ImportersItem>([&](ImportersRepo& repo) {
LockedItemRepository::read<ImportersItem>([&](const ImportersRepo& repo) {
uint index = repo.findIndex(item);
if (index) {
......
......@@ -137,7 +137,7 @@ class ItemRepositoryFor<IndexedInstantiationInformation>
uint standardInstantiationInformationIndex()
{
static uint idx = LockedItemRepository::op<IndexedInstantiationInformation>(
static uint idx = LockedItemRepository::write<IndexedInstantiationInformation>(
[standardInstantiationInformation = InstantiationInformation()](InstantiationInformationRepository& repo) {
return repo.index(standardInstantiationInformation);
});
......@@ -196,13 +196,13 @@ const InstantiationInformation& IndexedInstantiationInformation::information() c
{
auto index = m_index ? m_index : standardInstantiationInformationIndex();
// TODO: it's probably unsafe to return the const& here, as the repo won't be locked during access anymore
return *LockedItemRepository::op<IndexedInstantiationInformation>(
[index](InstantiationInformationRepository& repo) { return repo.itemFromIndex(index); });
return *LockedItemRepository::read<IndexedInstantiationInformation>(
[index](const InstantiationInformationRepository& repo) { return repo.itemFromIndex(index); });
}
IndexedInstantiationInformation InstantiationInformation::indexed() const
{
auto index = LockedItemRepository::op<IndexedInstantiationInformation>(
auto index = LockedItemRepository::write<IndexedInstantiationInformation>(
[this](InstantiationInformationRepository& repo) { return repo.index(*this); });
return IndexedInstantiationInformation(index);
}
......
......@@ -214,7 +214,7 @@ void PersistentSymbolTable::addDeclaration(const IndexedQualifiedIdentifier& id,
PersistentSymbolTableItem item;
item.id = id;
LockedItemRepository::op<PersistentSymbolTableItem>([&item, &declaration](PersistentSymbolTableRepo& repo) {
LockedItemRepository::write<PersistentSymbolTableItem>([&item, &declaration](PersistentSymbolTableRepo& repo) {
uint index = repo.findIndex(item);
if (index) {
......@@ -270,7 +270,7 @@ void PersistentSymbolTable::removeDeclaration(const IndexedQualifiedIdentifier&
PersistentSymbolTableItem item;
item.id = id;
LockedItemRepository::op<PersistentSymbolTableItem>([&item, &declaration](PersistentSymbolTableRepo& repo) {
LockedItemRepository::write<PersistentSymbolTableItem>([&item, &declaration](PersistentSymbolTableRepo& repo) {
uint index = repo.findIndex(item);
if (index) {
......@@ -384,7 +384,7 @@ PersistentSymbolTable::Declarations PersistentSymbolTable::declarations(const In
PersistentSymbolTableItem item;
item.id = id;
return LockedItemRepository::op<PersistentSymbolTableItem>([&item](const PersistentSymbolTableRepo& repo) {
return LockedItemRepository::read<PersistentSymbolTableItem>([&item](const PersistentSymbolTableRepo& repo) {
uint index = repo.findIndex(item);
if (index) {
......@@ -405,7 +405,7 @@ void PersistentSymbolTable::declarations(const IndexedQualifiedIdentifier& id, u
PersistentSymbolTableItem item;
item.id = id;
LockedItemRepository::op<PersistentSymbolTableItem>(
LockedItemRepository::read<PersistentSymbolTableItem>(
[&item, &countTarget, &declarationsTarget](const PersistentSymbolTableRepo& repo) {
uint index = repo.findIndex(item);
......@@ -481,7 +481,7 @@ void PersistentSymbolTable::dump(const QTextStream& out)
QDebug qout = fromTextStream(out);
DebugVisitor v(out);
LockedItemRepository::op<PersistentSymbolTableItem>([&](const PersistentSymbolTableRepo& repo) {
LockedItemRepository::read<PersistentSymbolTableItem>([&](const PersistentSymbolTableRepo& repo) {
repo.visitAllItems(v);
qout << "Statistics:" << endl;
......
......@@ -117,7 +117,7 @@ uint TypeRepository::indexForType(const AbstractType::Ptr& input)
if (!input)
return 0;
uint i = LockedItemRepository::op<AbstractTypeData>(
uint i = LockedItemRepository::write<AbstractTypeData>(
[request = AbstractTypeDataRequest(*input)](TypeItemRepository& repo) { return repo.index(request); });
#ifdef DEBUG_TYPE_REPOSITORY
AbstractType::Ptr t = typeForIndex(i);
......@@ -139,7 +139,7 @@ AbstractType::Ptr TypeRepository::typeForIndex(uint index)
if (index == 0)
return AbstractType::Ptr();
return LockedItemRepository::op<AbstractTypeData>([index](TypeItemRepository& repo) {
return LockedItemRepository::read<AbstractTypeData>([index](const TypeItemRepository& repo) {
auto item = repo.itemFromIndex(index);
return AbstractType::Ptr(TypeSystem::self().create(const_cast<AbstractTypeData*>(item)));
});
......@@ -150,7 +150,7 @@ void TypeRepository::increaseReferenceCount(uint index, ReferenceCountManager* m
if (!index)
return;
LockedItemRepository::op<AbstractTypeData>([&](TypeItemRepository& repo) {
LockedItemRepository::write<AbstractTypeData>([&](TypeItemRepository& repo) {
AbstractTypeData* data = repo.dynamicItemFromIndexSimple(index);
Q_ASSERT(data);
if (manager)
......@@ -165,7 +165,7 @@ void TypeRepository::decreaseReferenceCount(uint index, ReferenceCountManager* m
if (!index)
return;
LockedItemRepository::op<AbstractTypeData>([&](TypeItemRepository& repo) {
LockedItemRepository::write<AbstractTypeData>([&](TypeItemRepository& repo) {
AbstractTypeData* data = repo.dynamicItemFromIndexSimple(index);
Q_ASSERT(data);
Q_ASSERT(data->refCount > 0);
......
......@@ -138,7 +138,7 @@ void Uses::addUse(const DeclarationId& id, const IndexedTopDUContext& use)
item.usesList().append(use);
UsesRequestItem request(item);
LockedItemRepository::op<UsesItem>([&](UsesRepo& repo) {
LockedItemRepository::write<UsesItem>([&](UsesRepo& repo) {
uint index = repo.findIndex(item);
if (index) {
......@@ -164,7 +164,7 @@ void Uses::removeUse(const DeclarationId& id, const IndexedTopDUContext& use)
item.declaration = id;
UsesRequestItem request(item);
LockedItemRepository::op<UsesItem>([&](UsesRepo& repo) {
LockedItemRepository::write<UsesItem>([&](UsesRepo& repo) {
uint index = repo.findIndex(item);
if (index) {
......@@ -189,7 +189,7 @@ bool Uses::hasUses(const DeclarationId& id) const
UsesItem item;
item.declaration = id;
return LockedItemRepository::op<UsesItem>(
return LockedItemRepository::read<UsesItem>(
[&item](const UsesRepo& repo) { return static_cast<bool>(repo.findIndex(item)); });
}
......@@ -201,7 +201,7 @@ KDevVarLengthArray<IndexedTopDUContext> Uses::uses(const DeclarationId& id) cons
item.declaration = id;
UsesRequestItem request(item);
LockedItemRepository::op<UsesItem>([&](const UsesRepo& repo) {
LockedItemRepository::read<UsesItem>([&](const UsesRepo& repo) {
uint index = repo.findIndex(item);
if (index) {
......
......@@ -171,7 +171,7 @@ public:
void editRepo() const
{
if (m_index && !isSingleCharIndex(m_index)) {
LockedItemRepository::op<IndexedStringData>(*this);
LockedItemRepository::write<IndexedStringData>(*this);
}
}
......@@ -212,7 +212,7 @@ IndexedString::IndexedString(const char* str, unsigned short length, uint hash)
} else {
const auto request = IndexedStringRepositoryItemRequest(str, hash ? hash : hashString(str, length), length);
bool refcount = shouldDoDUChainReferenceCounting(this);
m_index = LockedItemRepository::op<IndexedStringData>([request, refcount](IndexedStringRepository& repo) {
m_index = LockedItemRepository::write<IndexedStringData>([request, refcount](IndexedStringRepository& repo) {
auto index = repo.index(request);
if (refcount) {
ReferenceCountChanger::increase(index)(repo);
......@@ -333,7 +333,7 @@ QString IndexedString::str() const
return QString(QLatin1Char(indexToChar(m_index)));
} else {
const uint index = m_index;
return LockedItemRepository::op<IndexedStringData>(
return LockedItemRepository::read<IndexedStringData>(
[index](const IndexedStringRepository& repo) { return stringFromItem(repo.itemFromIndex(index)); });
}
}
......@@ -350,7 +350,7 @@ int IndexedString::lengthFromIndex(uint index)
} else if (isSingleCharIndex(index)) {
return 1;
} else {
return LockedItemRepository::op<IndexedStringData>(
return LockedItemRepository::read<IndexedStringData>(
[index](const IndexedStringRepository& repo) { return repo.itemFromIndex(index)->length; });
}
}
......@@ -368,7 +368,7 @@ const char* IndexedString::c_str() const
return reinterpret_cast<const char*>(&m_index) + offset;
} else {
const uint index = m_index;
return LockedItemRepository::op<IndexedStringData>(
return LockedItemRepository::read<IndexedStringData>(
[index](const IndexedStringRepository& repo) { return c_strFromItem(repo.itemFromIndex(index)); });
}
}
......@@ -381,7 +381,7 @@ QByteArray IndexedString::byteArray() const
return QByteArray(1, indexToChar(m_index));
} else {
const uint index = m_index;
return LockedItemRepository::op<IndexedStringData>(
return LockedItemRepository::read<IndexedStringData>(
[index](const IndexedStringRepository& repo) { return arrayFromItem(repo.itemFromIndex(index)); });
}
}
......@@ -405,7 +405,7 @@ uint IndexedString::indexForString(const char* str, short unsigned length, uint
return charToIndex(str[0]);
} else {
const auto request = IndexedStringRepositoryItemRequest(str, hash ? hash : hashString(str, length), length);
return LockedItemRepository::op<IndexedStringData>(
return LockedItemRepository::write<IndexedStringData>(
[request](IndexedStringRepository& repo) { return repo.index(request); });
}
}
......
......@@ -2295,7 +2295,16 @@ class ItemRepositoryFor;
struct LockedItemRepository {
template <typename Item, typename Op>
static auto op(Op&& op)
static auto read(Op&& op)
{
const auto& repo = ItemRepositoryFor<Item>::repo();
QMutexLocker lock(repo.mutex());
return op(repo);
}
template <typename Item, typename Op>
static auto write(Op&& op)
{
auto& repo = ItemRepositoryFor<Item>::repo();
......
......@@ -21,7 +21,7 @@ struct ItemRepositoryReferenceCounting {
return false;
}
LockedItemRepository::op<Item>(
LockedItemRepository::write<Item>(
[&](auto& repo) { item->increase(repo.dynamicItemFromIndexSimple(index)->m_refCount, index); });
return true;
}
......@@ -35,7 +35,7 @@ struct ItemRepositoryReferenceCounting {
return false;
}
LockedItemRepository::op<Item>(
LockedItemRepository::write<Item>(
[&](auto& repo) { item->decrease(repo.dynamicItemFromIndexSimple(index)->m_refCount, index); });
return true;
}
......@@ -48,7 +48,7 @@ struct ItemRepositoryReferenceCounting {
}
if (shouldDoDUChainReferenceCounting(item)) {
LockedItemRepository::op<Item>([&](auto& repo) {
LockedItemRepository::write<Item>([&](auto& repo) {
if (m_index) {
item->decrease(repo.dynamicItemFromIndexSimple(m_index)->m_refCount, m_index);
}
......@@ -79,7 +79,7 @@ struct ItemRepositoryReferenceCounting {
return;
}
LockedItemRepository::op<Item>([&](auto& repo) {
LockedItemRepository::write<Item>([&](auto& repo) {
if (lhs_index && lhsShouldDoDUChainReferenceCounting) {
lhs->decrease(repo.dynamicItemFromIndexSimple(lhs_index)->m_refCount, lhs_index);
} else if (rhs_index && rhsShouldDoDUChainReferenceCounting && !lhsShouldDoDUChainReferenceCounting) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment