Skip to content

perf(core): cache $dynamicAnchor fallback index on context #3479

@aqeelat

Description

@aqeelat

When dynamicScope has no entry for an anchor, resolveDynamicRef scans all components.schemas on every call. For specs with many $dynamicRefs, this is O(numDynamicRefs × numSchemas).

Two improvements:

  1. Cache — lazily build a Map<anchorName, string[]> on the context so the scan runs once per spec
  2. Short-circuit — track first match + count instead of collecting all matches; bail early when ambiguous

Location: packages/core/src/resolvers/ref.ts around line 456-475.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type
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