Skip to content

Commit

Permalink
improve: only decay valid items
Browse files Browse the repository at this point in the history
  • Loading branch information
luan committed Sep 17, 2023
1 parent aef87fc commit 98293c4
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/items/decay/decay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,10 @@ void Decay::checkDecay() {

// Iterating here is unsafe so let's copy our items into temporary vector
auto &decayItems = it->second;
tempItems.reserve(tempItems.size() + decayItems.size());
for (auto &decayItem : decayItems) {
tempItems.push_back(decayItem.lock());
auto lockedDecayItems = weak::lock(decayItems);
tempItems.reserve(tempItems.size() + lockedDecayItems.size());
for (auto &decayItem : lockedDecayItems) {
tempItems.push_back(decayItem);
}
it = decayMap.erase(it);
}
Expand Down

0 comments on commit 98293c4

Please sign in to comment.