fix(layout): grow specs without contiguous reallocations

This commit is contained in:
2026-08-08 13:27:52 -04:00
parent 94ff3c5ca5
commit eea6366ea2
+6 -7
View File
@@ -138,21 +138,20 @@ constexpr uint16_t NO_LABEL = 0xFFFF;
class Tree { class Tree {
public: public:
std::vector<Node> nodes; std::vector<Node> nodes;
std::vector<Spec> specs; std::deque<Spec> specs;
const char* error = nullptr; const char* error = nullptr;
uint16_t focus = NONE; uint16_t focus = NONE;
// Growth doubling needs the old and new buffers live at once, which is the // Growth doubling needs the old and new node buffers live at once, which is
// allocation that fails first on a tight heap. One reservation covers a // the allocation that fails first on a tight heap. One reservation covers a
// typical screen so a build reallocates only if it genuinely gets large. // small screen so a build reallocates only if it genuinely gets large.
static constexpr size_t RESERVE = 64; static constexpr size_t NODE_RESERVE = 64;
void reset() { void reset() {
focus = NONE; focus = NONE;
nodes.clear(); nodes.clear();
specs.clear(); specs.clear();
nodes.reserve(RESERVE); nodes.reserve(NODE_RESERVE);
specs.reserve(RESERVE);
labelAt.clear(); labelAt.clear();
labels.clear(); labels.clear();
styles.clear(); styles.clear();