Skip to content

perf(FindChildFast): lazily index wide objects for repeated key lookups #2

Description

@iDavi

Affected function

FindChildFast in package/JSON.cls.

Problem

Each object-key lookup scans direct siblings. It is O(c) in the usual case and O(c x k) in the worst case, where c is the number of fields and k is key length.

Repeated calls such as StringKey, NumberKey, BoolKey, and ExistsKey against wide objects rescan the same fields.

Proposal

Build a normalized key-to-token-id index lazily for a container after repeated lookup, or expose an explicit indexing API. The implementation should not add a mandatory reference; a private open-addressing table or late-bound dictionary are possible designs.

Acceptance criteria

  • First lookup keeps the present low-allocation behavior.
  • Indexed repeated lookup is expected O(1).
  • Duplicate-key behavior is defined and tested.
  • Index lifetime is bound to the parsed document and does not change public API results.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions