From 4cbb6a93b9d46174cd86d6c9b6ecaeba3ba67e9d Mon Sep 17 00:00:00 2001 From: Simon Ochsenreither Date: Thu, 23 May 2013 21:04:00 +0200 Subject: SI-7511 Remove indirection of numeric methods Methods on `Rich`s like `abs`, `doubleValue`, `floatValue`, `longValue`, `intValue`, `byteValue`, `shortValue`, `min`, `max`, `signum` are slow because they go through multiple indirections including typeclasses and boxing. For instance, take `1L.abs`: Instead of just computing and returning the result (like it is done in `RichInt`), this is what happens: - `RichLong` inherits `abs` by extending `ScalaNumberProxy[T]` - `ScalaNumberProxy[T]` has an abstract `protected implicit def num: Numeric[T]` - This method is implemented in `RichLong` and points to `scala.math.Numeric.LongIsIntegral` - The actual method `abs` now calls `num.abs(self)` --- src/library/scala/math/ScalaNumericConversions.scala | 1 + 1 file changed, 1 insertion(+) (limited to 'src/library/scala/math') diff --git a/src/library/scala/math/ScalaNumericConversions.scala b/src/library/scala/math/ScalaNumericConversions.scala index 336991781e..0006133b13 100644 --- a/src/library/scala/math/ScalaNumericConversions.scala +++ b/src/library/scala/math/ScalaNumericConversions.scala @@ -20,6 +20,7 @@ trait ScalaNumericConversions extends ScalaNumber with ScalaNumericAnyConversion * across all the numeric types, suitable for use in value classes. */ trait ScalaNumericAnyConversions extends Any { + /** @return `'''true'''` if this number has no decimal component, `'''false'''` otherwise. */ def isWhole(): Boolean def underlying(): Any -- cgit v1.2.3