-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Reuse Printers with common options #52382
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
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
cd3afe4
Reuse Printers in symbolToStringWorker
jakebailey db730c9
Simplify greatly
jakebailey 9303902
Remove reset in API
jakebailey 8610e66
Minimize diff
jakebailey 6d99c8f
Reuse a lot more printers
jakebailey 4102e95
Reuse new createPrinter functions in symbolDisplay
jakebailey 28dfb91
Use a cache with a key on subset of options
jakebailey 2c3c9c8
Use strings
jakebailey bc7ad5d
Use a faster key, this one is twice as fast as the previous
jakebailey 521a00a
Restore previous formatting
jakebailey 82251a3
Go a little faster by comparing against undefined
jakebailey ce0f7ce
Revert "Go a little faster by comparing against undefined"
jakebailey 8f26dc1
Revert "Restore previous formatting"
jakebailey efe881c
Revert "Use a faster key, this one is twice as fast as the previous"
jakebailey 70076ea
Revert "Use strings"
jakebailey 4d7ab40
Revert "Use a cache with a key on subset of options"
jakebailey 708216a
Merge branch 'main' into pooled-printers
jakebailey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ import { | |
CallExpression, | ||
CheckFlags, | ||
contains, | ||
createPrinter, | ||
createPrinterWithRemoveComments, | ||
Debug, | ||
displayPart, | ||
EmitHint, | ||
|
@@ -75,7 +75,6 @@ import { | |
NodeBuilderFlags, | ||
ObjectFlags, | ||
operatorPart, | ||
Printer, | ||
PropertyAccessExpression, | ||
PropertyDeclaration, | ||
punctuationPart, | ||
|
@@ -259,7 +258,6 @@ export function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker: Typ | |
let hasAddedSymbolInfo = false; | ||
const isThisExpression = location.kind === SyntaxKind.ThisKeyword && isInExpressionContext(location) || isThisInTypeQuery(location); | ||
let type: Type | undefined; | ||
let printer: Printer; | ||
let documentationFromAlias: SymbolDisplayPart[] | undefined; | ||
let tagsFromAlias: JSDocTagInfo[] | undefined; | ||
let hasMultipleSignatures = false; | ||
|
@@ -730,10 +728,7 @@ export function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker: Typ | |
return { displayParts, documentation, symbolKind, tags: tags.length === 0 ? undefined : tags }; | ||
|
||
function getPrinter() { | ||
if (!printer) { | ||
printer = createPrinter({ removeComments: true }); | ||
} | ||
return printer; | ||
Comment on lines
-733
to
-736
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here's the code which already reused the printer; that being said, it only cached it once for each symbol, so it could totally be that this is a big improvement. Will have to rerun the benchmarks. |
||
return createPrinterWithRemoveComments(); | ||
} | ||
|
||
function prefixNextMeaning() { | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.