Skip to content

perf(sdui): cache visible row list and eliminate rows.any linear scan in SduiTreeBuilder.build() #1359

Closed

Description

@ZhuchkaTriplesix

Summary

In lib/features/connections/sdui_tree_builder.dart:

  1. Uncached tree traversal on every build:
    In build() (lines 188–189):
    final rows = _flattenVisible();
    Every time SduiTreeBuilder rebuilds (e.g. on row hover, selection change, scroll, or parent rebuild), _flattenVisible() walks the entire expanded tree and allocates a new List<_VisibleRow> with individual _VisibleRow.node objects for every visible node.
  2. Linear rows.any scan:
    In line 194:
    itemExtent: rows.any((r) => r.isError) ? null : _rowExtent,
    It runs rows.any(...), which traverses the entire flattened row list on every build. Meanwhile, _expandErrors is a Map<String, String> tracked in state, so checking _expandErrors.isNotEmpty is an (1)$ check that completely eliminates this list scan.

Proposed Solution

  1. Cache _visibleRows in state and only recompute when tree roots, expanded set, or load errors change.
  2. Replace rows.any((r) => r.isError) with _expandErrors.isNotEmpty.

Acceptance Criteria

  • Hovering over tree rows or updating selection does not re-walk the tree hierarchy or re-allocate visible rows.
  • itemExtent resolution uses (1)$ _expandErrors.isNotEmpty check.
  • Expanding/collapsing nodes and error retries continue to function identically.

Activity

  1. added
    frontendTheme parser epic label: frontend
    performanceTheme parser epic label: performance
    P2Medium priority / Parity & Refactoring
    on Oct 10, 2026
  2. ZhuchkaTriplesix commented on Oct 11, 2026

    @ZhuchkaTriplesix
    MemberAuthor

    Done in #1405 (merged into dev).

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 & RefactoringfrontendTheme parser epic label: frontendperformanceTheme parser epic label: performance

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions