You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
perf(grid): eliminate per-cell allocations of BoxDecoration, Border, and TextStyle in _GridCell via flyweight cache #1519
In lib/features/workspace/grid/grid_cell_renderer.dart (lines 112–168):
Inside _GridCell.build(), which runs for every visible cell in every visible row on every scroll event:
final style = material.TextStyle(...); // Allocates a new TextStylefinal bg = isSelected ? ... : ...;
decoration: material.BoxDecoration(
color: bg,
border: material.Border( // Allocates a new Border
right: material.BorderSide(...), // Allocates BorderSide instances
left: isSelectionLeft ? ... : ...,
top: isSelectionTop ? ... : ...,
bottom: ...,
),
),
For a typical grid view with 40 visible rows $\times$ 15 columns = 600 visible cells:
600 TextStyle objects
600 BoxDecoration objects
600 Border objects
1,200 BorderSide objects
~3,000 layout decoration allocations PER FRAME during fast scrolling.
Because every cell gets a newly instantiated BoxDecoration reference, Flutter's RenderDecoratedBox cannot short-circuit painting via identical(oldDecoration, newDecoration).
Architectural Solution: Flyweight Decoration Pool
Cell appearance states form a finite set of combinations:
striped (2 states)
isSelected (2 states)
rowStatus (clean / inserted / deleted) (3 states)
cellStatus (clean / modified) (2 states)
Precompute and pool the decoration instances in a compact lookup cache (Flyweight pattern) keyed by integer bitmask:
Activity
perf(grid): CJK font fallback for cells and the shared mono stack; ce…