You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 67a4c8b
Browse filesBrowse the repository at this point in the historyBrowse files
Cache JavaInput in Cleanups and fuse AST cleanup passes
Eliminates redundant full-file lexing and parsing across `Cleanups`,
`CleanupPass`, and `Formatter.getFormatReplacements`:
- Retain `ImmutableList<Tok>` on `JavaInput` (`getToks()`), cache `JavaInput` in
`Cleanups` (invalidated alongside `parsed` in `applyReplacements`), and return
it in `Cleanups.Result` so `CleanupScanner`, `ImportOrderer` (when `javaInput`
is already cached), `ModifierOrderer`, and `Formatter.getFormatReplacements`
share a single full-file lex instead of 3 full-file lexes + 1 prefix lex on
clean files.
- Fuse `REMOVE_UNUSED_IMPORTS` and `AST_CLEANUPS` onto a single shared
`JCCompilationUnit` parse (`applyFusedAstPasses`), passing
`preExistingDeletions` into `CleanupScanner` so adjacent deletions (such as
`import java.util.List;;`) remain identical.
- Order `SORT_IMPORTS` before `REORDER_MODIFIERS` in `CleanupPass` so when
imports are sorted (invalidating `javaInput`), `SORT_IMPORTS` only does a
prefix lex (`CLASS_START`) and `REORDER_MODIFIERS` then builds `JavaInput`
once for `Formatter` to reuse.
- Update `CleanupsTest` to cover fused AST pass behavior, `javaInput` reuse, and
adjacent unused-import + redundant-semicolon deletion.
Benchmarks (warm in-JVM `ThreadMXBean` CPU time):
- `JavaInputAstVisitor.java` (140 KB, clean): med 178.1 -> 146.1 ms (1.22x),
min 147.4 -> 105.2 ms (1.40x).
PiperOrigin-RevId: 1025905856
0 commit comments