[LVI] Remove count/erase idiom in favor of checking result value of erase

Minor compile time win.  Avoids an additional O(N) scan in the case where we are removing an element and costs nothing when we aren't.

llvm-svn: 290768
This commit is contained in:
Philip Reames 2016-12-30 22:09:10 +00:00
parent e7407ba1ef
commit fdbb05b469
1 changed files with 2 additions and 6 deletions

View File

@ -462,8 +462,7 @@ void LazyValueInfoCache::eraseValue(Value *V) {
SmallVector<AssertingVH<BasicBlock>, 4> ToErase;
for (auto &I : OverDefinedCache) {
SmallPtrSetImpl<Value *> &ValueSet = I.second;
if (ValueSet.count(V))
ValueSet.erase(V);
ValueSet.erase(V);
if (ValueSet.empty())
ToErase.push_back(I.first);
}
@ -533,12 +532,9 @@ void LazyValueInfoCache::threadEdgeImpl(BasicBlock *OldSucc,
bool changed = false;
for (Value *V : ValsToClear) {
// TODO: count and erase can be converted to a find/erase(itr) pattern
if (!ValueSet.count(V))
if (!ValueSet.erase(V))
continue;
ValueSet.erase(V);
// If we removed anything, then we potentially need to update
// blocks successors too.
changed = true;