Repository navigation
Conversation
Previously, sortedAndDistinctImports unconditionally appended a new line to the imports, which was redundant most of the time and later was fixed by prettyPrint. Now we explicitly check for that and avoid redundant transformation when it can be avoided. It has a negligible performance impact but is important for a later change with the reuse of Parser.parse results
Introduce FormattingContext that encapsulates partially formatted code state and PSI, and avoids invocations of Parser.parse when it is clearly redundant. On a properly formatted code, it reduces the number of parses from 6 to 1, leading to a ~40% throughput improvement. All public-API formatting steps now have an internal method that accepts KtFile directly
hick209
approved these changes
Jun 3, 2026
|
@hick209 has imported this pull request. If you are a Meta employee, you can view this in D108656440. |
cortinico
approved these changes
Jun 17, 2026
cortinico
left a comment
Contributor
There was a problem hiding this comment.
Review automatically exported from Phabricator review in Meta.
3 of 5 tasks
3 of 5 tasks
social4hyq
pushed a commit
to social4hyq/homebrew-core
that referenced
this pull request
Sep 20, 2026
ktfmt 0.64 Created-by: HarmonybrewBot Commit-by: HarmonybrewBot Merged-by: HarmonybrewBot Description: Created by `brew bump` --- Created with `brew bump-formula-pr`.<details> <summary>release notes</summary> <pre>### Changed * Reduced overall number of allocations to improve formatting performance (~6-7%) (Kotlin/ktfmt#620) – @qwwdfsad * Reuse results of `Parser.parse` (Kotlin/ktfmt#622) – @qwwdfsad * Fix trailing lambda with chained call indentation (Kotlin/ktfmt#626) – @ptitjes * Refactor build scripts (Kotlin/ktfmt#623) – @AbdullinAM * Switch in-repo formatting to simple local gradle task (#628) – @ZacSweers ### Fixed * Support name-based destructuring declarations. (Kotlin/ktfmt#629) – @goutamadwant Huge thanks to all the contributors! 🎉 **Full Changelog**: https://github.com/facebook/ktfmt/compare/v0.63...v0.64</pre> <p>View the full release notes at <a href="https://github.com/facebook/ktfmt/releases/tag/v0.64">https://github.com/facebook/ktfmt/releases/tag/v0.64</a>.</p> </details> <hr> See merge request: Harmonybrew/homebrew-core!12237
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.
Cuts down formatting time on coroutines from 4.7 to ~2.9-3 seconds.
All explanations are in commit messages (note: they should be reviewed separately, the first one addresses a non-functional but necessary change)
Partially addresses #619
Fixes #552