Skip to content

[Performance] Reduce repeated block-config scans in AST2BlockList._propertyOf #6126

@Rohit-rk07

Description

@Rohit-rk07

Problem

AST2BlockList._propertyOf() repeatedly:

  • scans config.body_blocks to resolve each block's metadata
  • recomputes connection slot indices (prev, child, next, second_child) via repeated indexOf

During large AST-to-blockList conversions, this becomes avoidable overhead in a hot path.

Why It Matters

JS import/export conversion speed impacts responsiveness when handling larger projects.

Proposed Change

  • Precompute a blockName -> config entry map once per toBlockList() call.
  • Cache computed connection indices per connection-array object and reuse them.

Scope

  • File: js/js-export/ast2blocklist.js
  • Methods: _treeToBlockList() / _propertyOf()

Acceptance Criteria

  • Output blockList structure and ordering remain unchanged.
  • Fallback behavior for unknown blocks remains unchanged.
  • Repeated linear scans/index lookups in _propertyOf() are removed or minimized via caching.
  • Existing ast2blocklist tests pass.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions