}
bool TypeSetByHwMode::operator==(const TypeSetByHwMode &VTS) const {
- bool HaveDefault = hasDefault();
- if (HaveDefault != VTS.hasDefault())
+ // The isSimple call is much quicker than hasDefault - check this first.
+ bool IsSimple = isSimple();
+ bool VTSIsSimple = VTS.isSimple();
+ if (IsSimple && VTSIsSimple)
+ return *begin() == *VTS.begin();
+
+ // Speedup: We have a default if the set is simple.
+ bool HaveDefault = IsSimple || hasDefault();
+ bool VTSHaveDefault = VTSIsSimple || VTS.hasDefault();
+ if (HaveDefault != VTSHaveDefault)
return false;
- if (isSimple()) {
- if (VTS.isSimple())
- return *begin() == *VTS.begin();
- return false;
- }
-
SmallDenseSet<unsigned, 4> Modes;
for (auto &I : *this)
Modes.insert(I.first);