Cache parsed path mapping patterns #44078
Conversation
@@ -6732,14 +6732,25 @@ namespace ts { | |||
return <T>changeAnyExtension(path, newExtension, extensionsToRemove, /*ignoreCase*/ false); | |||
} | |||
|
|||
export function tryParsePattern(pattern: string): Pattern | undefined { | |||
// This should be verified outside of here and a proper error thrown. | |||
Debug.assert(hasZeroOrOneAsteriskCharacter(pattern)); |
sheetalkamat
May 21, 2021
Member
Why did we remove the assert or requirement that users of this have this checked already?
amcasey
May 21, 2021
Author
Member
The check was duplicated between the caller and the assert (none needed it for other reasons - they were just doing it to satisfy this requirement). I didn't think the requirement made the API conceptually clearer or the implementation simpler - on the contrary, I thought it was preferable to gather all the checks into a single function.
amcasey
May 25, 2021
Author
Member
Perhaps your question was "what happened to the proper error?". It's still there - an undefined
result now indicates that an error should be reported.
If a project has many of them (e.g. 1800), parsing the patterns repeatedly can take up a lot of time.
Force push is a rebase onto master. Updates to follow. |
@typescript-bot pack this |
Hey @amcasey, I've packed this into an installable tgz. You can install it for testing by referencing it in your
and then running There is also a playground for this build and an npm module you can use via |
If a project has many of them (e.g. 1800), parsing the patterns repeatedly can take up a lot of time.
Specifically,
getOwnKeys
andhasZeroOrOneAsteriskCharacter
were showing up as self-time hotspots.