Merge pull request #12 from YosysHQ/fix-updateelements

Properly delete element from unordered_map
This commit is contained in:
David Shah 2018-08-02 09:03:57 +02:00 committed by GitHub
commit 62e61c44e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -70,12 +70,14 @@ void IdStringList::updateElements(Context *ctx, std::vector<IdString> elements)
} }
// For any elements that are in managed_ but not in new, delete them. // For any elements that are in managed_ but not in new, delete them.
for (auto &pair : managed_) { auto it = managed_.begin();
if (element_set.count(pair.first) != 0) { while (it != managed_.end()) {
continue; if (element_set.count(it->first) != 0) {
++it;
} else {
it = managed_.erase(it);
changed = true;
} }
managed_.erase(pair.first);
changed = true;
} }
// Return early if there are no changes. // Return early if there are no changes.