perf: Cache import mappings and index fuzzy matches for resolution
Two major optimizations for the ref resolution phase: 1. Cache extractImportMappings() results per file path — previously re-read and re-parsed the source file for every single ref from that file (e.g. 100 refs from one file = 100 identical file reads) 2. Replace linear scan in matchFuzzy() with a lazily-built case-insensitive Map index — O(1) lookup instead of iterating all function/method/class nodes for every unresolved ref. Also drop low-value prefix matching (confidence 0.3). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
44ea6af043
commit
ab9d7188c1
@@ -16,8 +16,8 @@ import {
|
||||
ResolutionContext,
|
||||
FrameworkResolver,
|
||||
} from './types';
|
||||
import { matchReference } from './name-matcher';
|
||||
import { resolveViaImport } from './import-resolver';
|
||||
import { matchReference, clearFuzzyIndex } from './name-matcher';
|
||||
import { resolveViaImport, clearImportMappingCache } from './import-resolver';
|
||||
import { detectFrameworks } from './frameworks';
|
||||
import { logDebug } from '../errors';
|
||||
|
||||
@@ -106,6 +106,8 @@ export class ReferenceResolver {
|
||||
this.qualifiedNameCache.clear();
|
||||
this.kindCache.clear();
|
||||
this.nodeByIdCache.clear();
|
||||
clearImportMappingCache();
|
||||
clearFuzzyIndex();
|
||||
this.cachesWarmed = false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user