Skip to content

perf(grid): eliminate per-row List allocations and dynamic regex in clipboard export #1524

Open

Description

@ZhuchkaTriplesix

Problem

In GridSelectionManager / clipboard formatting logic (lib/features/workspace/grid/grid_selection_manager.dart), exporting table data creates heavy GC overhead:

  1. toCsv and toTsv allocate a new final cells = <String>[]; on every single row, followed by cells.join(...). For 10,000 rows, this creates 10,000 intermediate lists.
  2. toJson instantiates RegExp(r'^0\d+$') dynamically on cell evaluations and builds Map<String, dynamic> for each row before serialization.

Solution

  • Stream cell contents directly into StringBuffer using index checks: if (c > startCol) buffer.write(delimiter).
  • Replace dynamic RegExp with static cached regex or integer code unit checks (codeUnitAt).
  • Eliminate intermediate row lists and per-row maps.

Benefits

  • 0 intermediate list allocations during CSV/TSV copy.
  • Significant throughput boost when copying tens of thousands of cells.

Activity

  1. added this to the 0.5.0 milestone on Oct 12, 2026
  2. added
    data-gridInteractive data grid, cell editor, filtering, groupings
    coreCore library logic and services
    P2Medium priority / Parity & Refactoring
    on Oct 12, 2026
  3. added a commit that references this issue on Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium priority / Parity & RefactoringcoreCore library logic and servicesdata-gridInteractive data grid, cell editor, filtering, groupingsenhancementNew feature or requestperformanceTheme parser epic label: performance

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions