New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add -Wperformance
lints for *Ref
boxing and nonlocal return
#9889
Conversation
-Xlint:nonlocal-return is supported for compatibility.
f47930a
to
de70802
Compare
It would be nice to report whether boxings are eliminated by optimizer after closure inlining. |
@som-snytt I don't doubt this will be merged in the end, but would you mind filling in the PR description, to aid reviewers? (But also as end-user documentation, since this is release-notable.) |
Let's wait to merge until @lrytz is available. |
0c14898
to
6654dcf
Compare
This is under-specified, but 2.13.8 says
and 2.13.9 will say
|
Those other commits must have been prompted by the warning. But IIRC they are a balance of style rather than benchmark-driven. Somewhere I must have seen someone's suggestion for the hand-rolled function object. |
I see that back in February 2020 my take on Harrison's PR was:
and, well, I still wonder about that a bit. but I don't recall my whole thought process, there. the implementation doesn't seem like a likely maintenance burden. and perhaps my previous thinking was merely pedantic. |
var result = immutable.Map.empty[K, CC[B]] | ||
m.foreach { case (k, v) => | ||
result = result + ((k, v.result())) | ||
object result extends Function[(K, Builder[B, CC[B]]), Unit] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use class
and AbstractFunction
? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I will also add a lint for that.
-Wperformance
lints for *Ref
boxing and nonlocal return
Warn when local variables are captured by lambdas or by-name args and moved to the heap.
The warnings are behind a new
-Wperformance
flag, as the user did nothing wrong but might be surprised by a difference in performance.Similarly,
-Xlint:nonlocal-return
is also enabled by the new flag, though it is not removed from-Xlint
.Revives #8691 by @hrhino.