Skip to content

perf(lsp): make auto-imports a little faster #28106

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 17, 2025
Merged
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
12 changes: 0 additions & 12 deletions cli/tsc/00_typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -125170,14 +125170,6 @@ function changeCompilerHostLikeToUseCache(host, toPath3, getSourceFile) {
}
return sourceFile;
} : void 0;
host.fileExists = (fileName) => {
const key = toPath3(fileName);
const value = fileExistsCache.get(key);
if (value !== void 0) return value;
const newValue = originalFileExists.call(host, fileName);
fileExistsCache.set(key, !!newValue);
return newValue;
};
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removes this cache because we always return false (which is questionable and something we should look into in the future, but no need to have a cache for a constant)

if (originalWriteFile) {
host.writeFile = (fileName, data, ...rest) => {
const key = toPath3(fileName);
Expand Down Expand Up @@ -165768,10 +165760,6 @@ function getDefaultCommitCharacters(isNewIdentifierLocation) {
return allCommitCharacters;
}
function getCompletionsAtPosition(host, program, log, sourceFile, position, preferences, triggerCharacter, completionKind, cancellationToken, formatContext, includeSymbol = false) {
return spanned("Tsc::getCompletionsAtPosition", () => getCompletionsAtPositionInner(host, program, log, sourceFile, position, preferences, triggerCharacter, completionKind, cancellationToken, formatContext, includeSymbol));
}

function getCompletionsAtPositionInner(host, program, log, sourceFile, position, preferences, triggerCharacter, completionKind, cancellationToken, formatContext, includeSymbol = false) {
var _a;
const { previousToken } = getRelevantTokens(position, sourceFile);
if (triggerCharacter && !isInString(sourceFile, position, previousToken) && !isValidTrigger(sourceFile, triggerCharacter, previousToken, position)) {
Expand Down
6 changes: 6 additions & 0 deletions cli/tsc/97_ts_host.js
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,12 @@ const hostImpl = {
}
return scriptSnapshot;
},
getNearestAncestorDirectoryWithPackageJson() {
// always return `undefined` in order to short-circuit
// a codepath in the TypeScript compiler that always
// ends up returning `undefined` in Deno anyway
return undefined;
},
};

// these host methods are super noisy (often thousands of calls per TSC request)
Expand Down