Optimize AssignedProtos::empty() to stop early

Also allow counting an `AssignedProtos`'s number of proto-palettes
This commit is contained in:
ISSOtm
2022-03-07 22:58:50 +01:00
committed by Eldred Habert
parent 3d79f76e41
commit a96aa1725f

View File

@@ -156,7 +156,13 @@ public:
}
void clear() { _assigned.clear(); }
bool empty() const { return std::distance(begin(), end()) == 0; }
bool empty() const {
return std::find_if_not(
_assigned.begin(), _assigned.end(),
[](std::optional<ProtoPalAttrs> const &slot) { return slot.has_value(); })
== _assigned.end();
}
size_t nbProtoPals() const { return std::distance(begin(), end()); }
private:
template<typename Iter>