-
Notifications
You must be signed in to change notification settings - Fork 22
Closed
Milestone
Description
(d: Double).isNan is compiled as Predef.double2Double(d).isNan(), which boxes the number.
Using Predef.doubleWrapper(1.0).isNaN would be preferable because RichDouble is a value class. However, doubleWrapper is a lower priority implicit than double2Double because it's defined in Predef's parent LowPriorityImplicits.
Other methods are also affected, e.g., longValue and friends, and using isInfinite boxes, where isInfinity doesn't.
Ideas:
- swap the priority of the two implicits; but it seems rather risky to fiddle with double2Double at this point
- rewrite the known calls in the backend
- rely on inlining (doesn't work currenlty, it the inliner only rewrites it to
new Double.isNan(d). Also, requires to enable inlining from the jdk, which is not recommended.) - rely on the jvm's escape analysis
Reactions are currently unavailable