-
-
Couldn't load subscription status.
- Fork 0
Open
Labels
priority: mediumMedium priority performance optimizationMedium priority performance optimization
Description
Summary
Cache lightweight import/export metadata for files touched by the move-file generator so that repeated checks avoid unnecessary reads and AST work.
Proposed Solution
interface FileMetadata {
hasImports: boolean;
hasExports: boolean;
knownSpecifiers: Set<string>;
}
const fileMetadataCache = new Map<string, FileMetadata>();
function getFileMetadata(tree: Tree, filePath: string): FileMetadata {
const cached = fileMetadataCache.get(filePath);
if (cached !== undefined) {
return cached;
}
const content = astCache.getContent(tree, filePath);
if (!content) {
return { hasImports: false, hasExports: false, knownSpecifiers: new Set() };
}
const metadata: FileMetadata = {
hasImports: content.includes('import') || content.includes('require'),
hasExports: content.includes('export'),
knownSpecifiers: extractSpecifiers(content),
};
fileMetadataCache.set(filePath, metadata);
return metadata;
}- Populate metadata on first access using cached file content.
- Consult metadata before re-reading or re-parsing files.
Tasks
- Define a
FileMetadatastructure and cache keyed by normalized file path - Populate metadata on first access using the existing content/AST cache
- Update import-related helpers to leverage the cached metadata before re-reading files
Definition of Done
- Existing benchmark and stress test suites are run before and after the change; document the findings in the PR description. Skipping this is not allowed.
- Unit/e2e tests must pass.
- Add comments/tests to cover the metadata cache lifecycle if necessary.
Metadata
Metadata
Assignees
Labels
priority: mediumMedium priority performance optimizationMedium priority performance optimization