Caching splitted and trimmed lines for indentable block comments#18981
Merged
fisker merged 11 commits intoprettier:mainfrom Apr 12, 2026
Merged
Caching splitted and trimmed lines for indentable block comments#18981fisker merged 11 commits intoprettier:mainfrom
fisker merged 11 commits intoprettier:mainfrom
Conversation
commit: |
✅ Deploy Preview for prettier ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for prettier ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
fisker
reviewed
Mar 28, 2026
fisker
reviewed
Mar 28, 2026
Janther
commented
Mar 29, 2026
|
|
||
| const trimmedLines = []; | ||
|
|
||
| for (let line of `*${comment.value}*`.split("\n")) { |
Contributor
Author
There was a problem hiding this comment.
@fisker I added a last commit to this where instead of doing 2 iterations, one to trimStart and one to check startsWith("*"), there is only one iteration where we early exit as soon as we fail the check. (similar to how Array.prototype.every() works)
Also the cache now is an array of the indentable lines, and an empty array if the block is not indentable. This way we can remove the original cache since now it's only a check for the length of the indentable lines.
06bace6 to
7b051fd
Compare
fisker
approved these changes
Apr 12, 2026
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.
Description
isIndentableBlockCommentandprintIndentableBlockCommentbothsplitandtrimthevalueof acommentI suspect this is why you decided to cacheisIndentableBlockComment.I propose to cache the splitter trimmed lines. so the printing won't have to do extra work.
This might even remove the need for the original cache for
isIndentableBlockComment.Checklist
docs/directory).changelog_unreleased/*/XXXX.mdfile followingchangelog_unreleased/TEMPLATE.md.