AliasSet::NodeInfo operandInfo(compiler, operand);
if (operandInfo.IsLclVarRead())
{
- int count = 0;
- if (unconsumedLclVarReads.TryRemove(operandInfo.LclNum(), &count) && count > 1)
+ int count;
+ const bool removed = unconsumedLclVarReads.TryRemove(operandInfo.LclNum(), &count);
+ assert(removed);
+
+ if (count > 1)
{
unconsumedLclVarReads.AddOrUpdate(operandInfo.LclNum(), count - 1);
}
}
AliasSet::NodeInfo nodeInfo(compiler, node);
-
- bool unused;
- if (nodeInfo.IsLclVarRead() && !unusedDefs.TryGetValue(node, &unused))
+ if (nodeInfo.IsLclVarRead() && !unusedDefs.Contains(node))
{
int count = 0;
unconsumedLclVarReads.TryGetValue(nodeInfo.LclNum(), &count);
unconsumedLclVarReads.AddOrUpdate(nodeInfo.LclNum(), count + 1);
}
- if (nodeInfo.IsLclVarWrite())
- {
- int unused;
- assert(!unconsumedLclVarReads.TryGetValue(nodeInfo.LclNum(), &unused));
- }
+ // If this node is a lclVar write, it must be to a lclVar that does not have an outstanding read.
+ assert(!nodeInfo.IsLclVarWrite() || !unconsumedLclVarReads.Contains(nodeInfo.LclNum()));
}
return true;
*value = m_buckets[index].m_value;
return true;
}
+
+ //------------------------------------------------------------------------
+ // HashTableBase::Contains: returns true if a key exists in the table and
+ // false otherwise.
+ //
+ // Arguments:
+ // key - The key to find from the table.
+ //
+ // Returns:
+ // True if the key was found in the table; false otherwise.
+ bool Contains(const TKey& key) const
+ {
+ unsigned unused, index;
+ return TryGetBucket(TKeyInfo::GetHashCode(key), key, &unused, &index);
+ }
};
//------------------------------------------------------------------------