fix(layout): grow specs without contiguous reallocations
This commit is contained in:
@@ -138,21 +138,20 @@ constexpr uint16_t NO_LABEL = 0xFFFF;
|
||||
class Tree {
|
||||
public:
|
||||
std::vector<Node> nodes;
|
||||
std::vector<Spec> specs;
|
||||
std::deque<Spec> specs;
|
||||
const char* error = nullptr;
|
||||
uint16_t focus = NONE;
|
||||
|
||||
// Growth doubling needs the old and new buffers live at once, which is 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.
|
||||
static constexpr size_t RESERVE = 64;
|
||||
// Growth doubling needs the old and new node buffers live at once, which is
|
||||
// the allocation that fails first on a tight heap. One reservation covers a
|
||||
// small screen so a build reallocates only if it genuinely gets large.
|
||||
static constexpr size_t NODE_RESERVE = 64;
|
||||
|
||||
void reset() {
|
||||
focus = NONE;
|
||||
nodes.clear();
|
||||
specs.clear();
|
||||
nodes.reserve(RESERVE);
|
||||
specs.reserve(RESERVE);
|
||||
nodes.reserve(NODE_RESERVE);
|
||||
labelAt.clear();
|
||||
labels.clear();
|
||||
styles.clear();
|
||||
|
||||
Reference in New Issue
Block a user