Revert "fix(layout): reserve growable tree vectors up front to avoid bad_alloc"

This reverts commit 873e003c45.
This commit is contained in:
2026-08-08 12:58:25 -04:00
parent 5d44234046
commit 4568f56f92
+1 -12
View File
@@ -144,10 +144,7 @@ public:
// 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.
// 512 skips most growth-doubling reallocs during a build (a typical screen is
// ~300 nodes); 64 forced 4-5 doubling moves, each fragmenting the heap while
// old and new buffers are both live.
static constexpr size_t RESERVE = 512;
static constexpr size_t RESERVE = 64;
void reset() {
focus = NONE;
@@ -159,14 +156,6 @@ public:
labels.clear();
styles.clear();
scrollState.clear();
// Reserve every growable vector while the heap still has a large contiguous
// block. A doubling realloc mid-build needs old+new live at once and throws
// bad_alloc on a heap the build has already fragmented -- the styles vector
// is what the global new-handler caught and turned into a reset. styles is
// sparser than nodes; labels is a byte arena.
labelAt.reserve(RESERVE);
styles.reserve(RESERVE / 2);
labels.reserve(1024);
error = nullptr;
}