LayoutBuilder caches the owned BastDoc (ADR-012 §2a, plan phase 4)
The builder stores doc: BastDoc + endian (the doc_value: Value + root_name: String cache is gone); new parses the typed tree once and build walks &self.doc — the per-build BastDoc::new re-parse (layout_builder.rs M1) is retired. - build's root-is-struct re-check replaces its unreachable!() with a clean Schema error (AGENTS.md §3 never-panic; invariant unchanged — new already rejects non-struct roots). - Boxing fallout: the builder now holds the full owned tree, so Layout::Packed boxes it (Box<LayoutBuilder>) to keep the engine's Layout enum variant sizes balanced (clippy large_enum_variant). layout_builder() still returns Option<&LayoutBuilder> via auto-deref; public API unchanged. Verification: 465 tests pass unchanged (layout_builder.rs suites drive new/build through the public API); clippy -D warnings clean; wasm32 release build green.
This commit is contained in:
1 parent
c583762352
commit
b7c7dbe2a1
3 files changed
+28
-17
No files matched your search
@@ -482,7 +482,20 @@ wasm-relevant).
|
||||
|
||||
---
|
||||
|
||||
## Phase 4 — `LayoutBuilder` caches the owned `BastDoc` (ADR-012 §2a)
|
||||
## Phase 4 — `LayoutBuilder` caches the owned `BastDoc` (ADR-012 §2a) — **DONE (2026-09-02)**
|
||||
|
||||
> **Status: implemented.** `LayoutBuilder` stores `doc: BastDoc` +
|
||||
> `endian` (the `doc_value: Value` + `root_name: String` cache is
|
||||
> gone); `new` parses once, `build` walks `&self.doc` — the
|
||||
> `layout_builder.rs` re-parse (M1) is retired. The `build`-time
|
||||
> root-is-struct re-check replaced its `unreachable!()` with a clean
|
||||
> `Schema` error (AGENTS.md §3 never-panic; the invariant is
|
||||
> unchanged — `new` already rejects non-struct roots). Boxing fallout:
|
||||
> the builder now holds the full owned tree, so `Layout::Packed`
|
||||
> boxes it (`builder: Box<LayoutBuilder>`) to keep the engine's
|
||||
> `Layout` enum variant sizes balanced (clippy
|
||||
> `large_enum_variant`); `layout_builder()` still returns
|
||||
> `Option<&LayoutBuilder>` via auto-deref, public API unchanged.
|
||||
|
||||
**Goal:** `LayoutBuilder::new` parses the owned `BastDoc` once and
|
||||
stores it; `build` reuses it. Removes the `layout_builder.rs:190`
|
||||
|
||||
Reference in new issue
Block a user