Reuse chat table cell measurements across rebuilds

A markdown table measures each cell's paragraph at infinite width before
laying it out. Cells rebuilt when a row scrolls back in or a chat is opened
again now reuse those widths from a bounded cache keyed by the cell markdown
and its paragraph style, cleared when fonts change. Layout is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-22 18:24:11 +00:00
parent 58c72538d5
commit 914ecb285d
4 changed files with 179 additions and 1 deletions
+8
View File
@@ -50,6 +50,14 @@ timeline) in the self-time lists are measurement overhead.
out for its max width, its min width and then its real width. Caching per
cell text, or skipping the min pass when the max widths already fit, cuts
it.
Change (2026-11-22): the min pass was already free (RenderParagraph
answers min and max from one infinite-width layout of its intrinsics
painter), so skipping it saves nothing. `chat_table_cell_measure.dart`
now caches each cell's min/max width across render objects, keyed by the
cell's markdown and its paragraph's style, scaler, direction and locale,
cleared on font changes. A table that scrolls back in or a chat opened
again lays each cell out once (its real width) instead of twice; a first
view still measures. Not yet re-benchmarked.
4. **Per-delta transcript rebuild**: `transcriptRows` 41 ms,
`withChatShownItems` 28 ms (`_rowTime` 15 ms), `ChatRowKeys.forRows`
16 ms, `sliver_animated_extent` layout 250 ms inclusive over the stream.