Skip to content

perf(grid): cheaper per-row filter predicates, one selection test per row, cheaper clipboard export - #1681

Merged
ZhuchkaTriplesix merged 2 commits into
devfrom
perf/grid-filter-selection-hot-paths
Oct 17, 2026
Merged

ZhuchkaTriplesix merged 2 commits into
devfrom
perf/grid-filter-selection-hot-paths

Conversation

@ZhuchkaTriplesix

Copy link
Copy Markdown
Member

From the review of conditions on hot paths. Refs #1550.

Filter (grid_filter_engine.dart, runs once per row)

  • A predicate no longer parses the cell as a number unless its target is a number (a text target used to pay trim + double.tryParse on every cell).
  • The operator is resolved to an enum when the predicate is built; evaluate no longer walks three string switches per row.
  • _FreeTextNode lower-cases its term once, not per row. The substring fallback lower-cases each cell once per row, not once per term.

Grid rows (grid_row_renderer.dart): the selection test is done once per row and once per cell instead of up to six times per cell.

Clipboard (grid_selection_manager.dart)

  • toJson: a cheap first-character check before the two number parses, and an allocation-free true/false comparison. Side effect: text such as Infinity / NaN stays text instead of becoming a double that jsonEncode cannot encode.
  • CSV/TSV escaping is one pass over the code units instead of four contains scans.

Tests for numeric vs text targets, case-insensitive free text, JSON edge values and CSV/TSV quoting. Not measured; the gains are estimated from the code.

… cell only for numeric targets; one selection test per row; cheaper clipboard export
@ZhuchkaTriplesix
ZhuchkaTriplesix merged commit b16cb80 into dev Oct 17, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant