diff --git a/components/esm3/infoorder.hpp b/components/esm3/infoorder.hpp index 77b80e3d20..154cf8970f 100644 --- a/components/esm3/infoorder.hpp +++ b/components/esm3/infoorder.hpp @@ -24,14 +24,15 @@ namespace ESM auto it = mInfoPositions.find(value.mId); - if (it != mInfoPositions.end() && it->second.mPosition->mPrev == value.mPrev) + if (it != mInfoPositions.end()) { + bool samePrev = it->second.mPosition->mPrev == value.mPrev; *it->second.mPosition = std::forward(value); it->second.mDeleted = deleted; - return; + if (samePrev) + return; } - - if (it == mInfoPositions.end()) + else it = mInfoPositions.emplace(value.mId, Item{ .mPosition = mOrderedInfo.end(), .mDeleted = deleted }) .first; @@ -57,13 +58,6 @@ namespace ESM return; } - const auto nextIt = mInfoPositions.find(value.mNext); - if (nextIt != mInfoPositions.end()) - { - insertOrSplice(nextIt->second.mPosition); - return; - } - insertOrSplice(mOrderedInfo.end()); }