Skip to content

Small visitor performance tweaks#1703

Merged
wmdietl merged 7 commits into
masterfrom
visitor-perf
May 11, 2026
Merged

Small visitor performance tweaks#1703
wmdietl merged 7 commits into
masterfrom
visitor-perf

Conversation

@wmdietl
Copy link
Copy Markdown
Member

@wmdietl wmdietl commented May 11, 2026

No description provided.

Copilot AI review requested due to automatic review settings May 11, 2026 16:24
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_EXPRESSION kind lookup and use it in scan to 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 in InitializationVisitor, 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.

Comment thread framework/src/main/java/org/checkerframework/common/basetype/BaseTypeVisitor.java Outdated
wmdietl and others added 2 commits May 11, 2026 14:13
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@wmdietl wmdietl merged commit cc9dd93 into master May 11, 2026
50 checks passed
@wmdietl wmdietl deleted the visitor-perf branch May 11, 2026 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants