mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-25 16:43:33 +00:00
Change control flow to be easier to understand
This commit is contained in:
parent
09147934fb
commit
4eac137109
@ -38,27 +38,19 @@ namespace ESM
|
|||||||
|
|
||||||
Item& item = it->second;
|
Item& item = it->second;
|
||||||
|
|
||||||
const auto insertOrSplice = [&](typename std::list<T>::const_iterator before) {
|
auto before = mOrderedInfo.begin();
|
||||||
if (item.mPosition == mOrderedInfo.end())
|
if (!value.mPrev.empty())
|
||||||
item.mPosition = mOrderedInfo.insert(before, std::forward<V>(value));
|
{
|
||||||
|
const auto prevIt = mInfoPositions.find(value.mPrev);
|
||||||
|
if (prevIt != mInfoPositions.end())
|
||||||
|
before = std::next(prevIt->second.mPosition);
|
||||||
else
|
else
|
||||||
mOrderedInfo.splice(before, mOrderedInfo, item.mPosition);
|
before = mOrderedInfo.end();
|
||||||
};
|
|
||||||
|
|
||||||
if (value.mPrev.empty())
|
|
||||||
{
|
|
||||||
insertOrSplice(mOrderedInfo.begin());
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
if (item.mPosition == mOrderedInfo.end())
|
||||||
const auto prevIt = mInfoPositions.find(value.mPrev);
|
item.mPosition = mOrderedInfo.insert(before, std::forward<V>(value));
|
||||||
if (prevIt != mInfoPositions.end())
|
else
|
||||||
{
|
mOrderedInfo.splice(before, mOrderedInfo, item.mPosition);
|
||||||
insertOrSplice(std::next(prevIt->second.mPosition));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
insertOrSplice(mOrderedInfo.end());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void removeInfo(const RefId& infoRefId)
|
void removeInfo(const RefId& infoRefId)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user