Skip to content

Optimize determining boxed primitive types#1648

Open
wmdietl wants to merge 1 commit intomasterfrom
boxedtypes
Open

Optimize determining boxed primitive types#1648
wmdietl wants to merge 1 commit intomasterfrom
boxedtypes

Conversation

@wmdietl
Copy link
Copy Markdown
Member

@wmdietl wmdietl commented Apr 21, 2026

No description provided.

Copilot AI review requested due to automatic review settings April 21, 2026 01:44
@wmdietl
Copy link
Copy Markdown
Member Author

wmdietl commented Apr 21, 2026

@copilot Can you measure whether this has any performance benefit compared to CI running on master?

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

Note

Copilot was unable to run its full agentic suite in this review.

Improves performance of boxed-primitive detection by avoiding expensive qualified-name extraction when the declared type’s simple name cannot match a boxed primitive.

Changes:

  • Adds an early “fast reject” path based on TypeElement + simple-name checks before calling TypesUtils.getQualifiedName.
  • Introduces isPossiblyBoxedSimpleName(Name) helper to centralize the simple-name comparisons.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +146 to +148
// Fast reject: all boxed primitives are in java.lang and have short names.
// A DeclaredType whose asElement is not a TypeElement, or whose simple name
// doesn't match one of 8 known short names, can't be boxed.
Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

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

The comment implies the fast-reject validates “in java.lang”, but the code only checks the simple name and still relies on the later qualified-name lookup to confirm the package/class. To avoid misleading future maintainers, update the comment (and/or the helper Javadoc) to explicitly state this is a heuristic prefilter that does not validate the package.

Copilot uses AI. Check for mistakes.
Comment on lines +170 to +179
private static boolean isPossiblyBoxedSimpleName(Name n) {
return n.contentEquals("Byte")
|| n.contentEquals("Boolean")
|| n.contentEquals("Character")
|| n.contentEquals("Double")
|| n.contentEquals("Float")
|| n.contentEquals("Integer")
|| n.contentEquals("Long")
|| n.contentEquals("Short");
}
Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

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

This hard-coded list duplicates information that already exists in the boxedToPrimitiveType mapping, creating a risk that the two fall out of sync if boxed types are ever adjusted. Consider deriving the simple-name allowlist from the existing map once (e.g., a static Set<String> of simple names built from the map’s keys), and have isPossiblyBoxedSimpleName query that set (still using Name.contentEquals against the set’s entries or by converting Name to String only after a cheap length/first-char gate).

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown

Copilot AI commented Apr 21, 2026

@copilot Can you measure whether this has any performance benefit compared to CI running on master?

I measured what is currently available from Actions. The master baseline at base SHA 70671f2 (run 24644042584) took about 2h09m total workflow time, with 30 completed jobs (about 476 aggregate job-minutes). The PR run for commit 1d6d1dd (run 24699698377) is still queued, so there is no completed timing yet for a direct CI-to-CI comparison. Once that run finishes, I can provide an exact delta against master. (commit: 1d6d1dd)

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.

3 participants