Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions internal/checker/relater.go
Original file line number Diff line number Diff line change
Expand Up @@ -4332,6 +4332,17 @@ func (r *Relater) isPropertySymbolTypeRelated(sourceProp *ast.Symbol, targetProp
return TernaryTrue
}
effectiveSource := getTypeOfSourceProperty(sourceProp)
// Fast path: query the relation cache directly before entering the recursive comparison
// path. This avoids the overhead of calling into isRelatedToEx and its normalization
// logic when the result is already cached (e.g. for repeated property types like string
// or "off"|"warn"|"error" across 100+ properties in large object literals).
if effectiveSource.flags&TypeFlagsObject != 0 && effectiveTarget.flags&TypeFlagsObject != 0 {
id, _ := getRelationKey(effectiveSource, effectiveTarget, intersectionState, r.relation == r.c.identityRelation, false /*ignoreConstraints*/)
if entry := r.relation.get(id); entry != RelationComparisonResultNone && entry&RelationComparisonResultSucceeded != 0 {
r.c.reliabilityFlags |= entry & (RelationComparisonResultReportsUnmeasurable | RelationComparisonResultReportsUnreliable)
return TernaryTrue
}
}
return r.isRelatedToEx(effectiveSource, effectiveTarget, RecursionFlagsBoth, reportErrors, nil /*headMessage*/, intersectionState)
}

Expand Down
Loading