Scala 2.10, Double.isNaN and boxing

someDouble.isNaNIs Scala 2.10 expected in the field? By running my code calling .isNaNthrough the decompiler, I still see the control calls double2Doublein my code. Given that the new work AnyValworks in 2.10, I expect it to be no worse java.lang.Double.isNaN(someDouble)at run time without false allocations. Did I miss something?

+5
source share
1 answer

Unfortunately, isNaNthis is a method on java.lang.Double, and it is important to have an implicit conversion to java.lang.Double, so the Scala value class RichDoublecannot override isNaNto be fast, and when you use isNaN, you can specify java.lang.Double.

NaN,

implicit class RicherDouble(val d: Double) extends AnyVal {
  def nan = java.lang.Double.isNaN(d)
}

.nan .

+6

All Articles