perf(pnp): store inlined pnp data in multiline string literal#3977
Merged
perf(pnp): store inlined pnp data in multiline string literal#3977
Conversation
merceyz
previously approved these changes
Jan 15, 2022
a20dd85 to
4e82d41
Compare
merceyz
approved these changes
Jan 18, 2022
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What's the problem this PR addresses?
As @merceyz said in #3965 (comment), parsing JSON strings is more efficient than parsing JS object literals.
Closes #3965.
How did you fix it?
Made the inlined PnP data get stored in a multiline string literal (where newlines are escaped using
\) containing JSON.Why a multiline string literal over a template literal? @merceyz originally looked into using a template literal in #3965 (comment), but it turned out to be slower than even an object literal. More context: nodejs/node#41448
@merceyz ran some benchmarks on the next.js repo:
Checklist