Small visitor performance tweaks#1703
Merged
Merged
Conversation
checkContractsSubset return boolean, and fold their results into checkOverride's return value.
There was a problem hiding this comment.
Pull request overview
This PR makes small performance-oriented tweaks in visitor code paths, primarily by avoiding repeated computations and expensive operations during type-checking.
Changes:
- Add a runtime-safe
SWITCH_EXPRESSIONkind lookup and use it inscanto avoid per-node string/version checks. - Avoid materializing
tree.toString()in the slow-typechecking warning path by using source-position span as a cheap size proxy, and add a small cache for thrown-expression upper-bound annotations. - Minor micro-optimizations/cleanup: cache lint option lookup in
NullnessNoInitVisitor, reorder loops to short-circuit earlier inInitializationVisitor, and reduce repeated getter calls in a few hot methods.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| framework/src/main/java/org/checkerframework/framework/type/AnnotatedTypeFactory.java | Adds TODO notes about varargs expansion being tied to type-argument inference. |
| framework/src/main/java/org/checkerframework/common/basetype/BaseTypeVisitor.java | Main performance tweaks: switch-expression kind caching, cheaper slow-typechecking size heuristic, caching throw upper-bound annotations, and some local refactorings. |
| checker/src/main/java/org/checkerframework/checker/nullness/NullnessNoInitVisitor.java | Caches a lint option value and avoids repeated receiver-type queries. |
| checker/src/main/java/org/checkerframework/checker/initialization/InitializationVisitor.java | Reorders nested loops with labeled breaks to short-circuit after the first match. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.
No description provided.