mirror of
https://github.com/gbdev/rgbds.git
synced 2026-10-06 12:15:39 +00:00
Optimize AssignedProtos::empty() to stop early
Also allow counting an `AssignedProtos`'s number of proto-palettes
This commit is contained in:
1 parent
3d79f76e41
commit
a96aa1725f
1 file changed
+7
-1
@@ -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>
|
||||
|
||||
Reference in new issue
Block a user