Performance tuning
According to benchmarks within this codebase, the changes below may be responsible for 50-60% reduction in memory allocations and wall-clock time of the formatter; this does not take into account I/O to read in a file and write it out.
A set of assisted changes intended to improve performance:
- TreeOps/FormatTokens: read tree tokens via Origin, drop Tokens slices (#5317) @kitbellew
- benchmarks: parameterize styles, add Scala 3 case (#5318) @kitbellew
- drop Option/Either on hot token/tree/split paths (#5316) @kitbellew
- Splits/Router dispatch: ju.HashMap lookup + null/empty-Seq cascade (#5313) @kitbellew
- TreeOps: treeAt collects children into a de-captured loop (#5312) @kitbellew
- use tree.begOffset/endOffset/foreachChild (#5311) @kitbellew
- search loop: cut per-state and init-time allocation (#5308) @kitbellew
- benchmarks: modernize JVM options and harness (#5307) @kitbellew
- FormatWriter: pre-size mkString StringBuilder to source length (#5309) @kitbellew
Additional algorithm improvements:
- BestFirstSearch: increase block width by indent (#5284) @kitbellew
- BestFirstSearch: recurse on some longer blocks (#5283) @kitbellew
Features
- RewriteScala3Settings: common style guide preset (#5304) @kitbellew
- this is an attempt to approximate the common style recommendation
Bug fixes
- State: fix computing indent for StateColumn (#5292) @kitbellew
- release-native: disable trap-based GC yieldpoints (#5289) @gmethvin
- Splits: honor blank line before
else(#5288) @kitbellew
Miscellaneous
- tests: share munit config via SharedFunSuiteBase (#5315) @kitbellew
- Add tests around fewer braces and partial func (#5314) @kitbellew
- State: refactor processing next indents (#5291) @kitbellew
- FormatOps: pass ScalafmtConfig to getElseToken (#5287) @kitbellew
- TreeOps: add
isCurlyWithNextKeyword(#5286) @kitbellew
Build and dependency updates
- scalameta: upgrade to v4.17.2 (#5328) @kitbellew
- munit: upgrade to v1.3.4 (#5327) @kitbellew
- Update scala3-library, ... to 3.3.8 (#5323) @scala-steward
- Update sbt-native-image to 0.5.0 (#5326) @scala-steward
- Update munit, munit-diff to 1.3.3 (#5325) @scala-steward
- Update sbt-scalajs, scalajs-compiler, ... to 1.22.0 (#5322) @scala-steward
- Update jline to 3.30.15 (#5321) @scala-steward
- Update sbt-mima-plugin to 1.1.6 (#5320) @scala-steward
- Update sbt, scripted-plugin to 1.12.13 (#5324) @scala-steward
- Update sbt-ci-release to 1.12.0 (#5319) @scala-steward
- scalameta: upgrade to v4.17.1 (#5310) @kitbellew
- Bump actions/checkout from 6 to 7 (#5305) @dependabot[bot]
- formatter: upgrade to v3.11.1 (#5302) @kitbellew
- Update sbt-scalafmt to 2.6.1 (#5300) @scala-steward
- Update sbt, scripted-plugin to 1.12.11 (#5297) @scala-steward
- Update sbt-native-image to 0.4.0 (#5299) @scala-steward
- Update sbt-mima-plugin to 1.1.5 (#5295) @scala-steward
- Update typesafe:config to 1.4.9 (#5294) @scala-steward
- Update munit, munit-diff to 1.3.2 (#5298) @scala-steward
- Update jline to 3.30.13 (#5296) @scala-steward
- SBT: use correct scalacOptions for scala3 (#5293) @kitbellew
- Update to Scala Native 0.5.12 (#5285) @gmethvin