diff options
author | Simon Ochsenreither <simon@ochsenreither.de> | 2013-05-23 21:04:00 +0200 |
---|---|---|
committer | Simon Ochsenreither <simon@ochsenreither.de> | 2013-06-23 18:18:51 +0200 |
commit | 4cbb6a93b9d46174cd86d6c9b6ecaeba3ba67e9d (patch) | |
tree | 80032e4f62d92439ce8a8b78470658c984198647 /src/library/scala/math | |
parent | b6bc53479984f9fc0528a8ce3f6f0b582cb4147f (diff) | |
download | scala-4cbb6a93b9d46174cd86d6c9b6ecaeba3ba67e9d.tar.gz scala-4cbb6a93b9d46174cd86d6c9b6ecaeba3ba67e9d.tar.bz2 scala-4cbb6a93b9d46174cd86d6c9b6ecaeba3ba67e9d.zip |
SI-7511 Remove indirection of numeric methods
Methods on `Rich<AnyVal>`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)`
Diffstat (limited to 'src/library/scala/math')
-rw-r--r-- | src/library/scala/math/ScalaNumericConversions.scala | 1 |
1 files changed, 1 insertions, 0 deletions
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 |