ref: a96aa1725f6d0760d3df39c5a1a44eb196f7c8c6
parent: 3d79f76e416c90223cb21cae118c41ace021da2c
author: ISSOtm <eldredhabert0@gmail.com>
date: Mon Mar 7 17:58:50 EST 2022
Optimize `AssignedProtos::empty()` to stop early Also allow counting an `AssignedProtos`'s number of proto-palettes
--- a/src/gfx/pal_packing.cpp
+++ b/src/gfx/pal_packing.cpp
@@ -156,7 +156,13 @@
}
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>