diff options
author | Iulian Dragos <jaguarul@gmail.com> | 2009-05-13 15:12:24 +0000 |
---|---|---|
committer | Iulian Dragos <jaguarul@gmail.com> | 2009-05-13 15:12:24 +0000 |
commit | 40c11466e6235b6834093b79b12fb5e2bf7807f9 (patch) | |
tree | 7735df639559f076d6c8d06c5334037ce25a0de9 | |
parent | 1b9f19f08560f324aee6632643ec2bd1187dec1a (diff) | |
download | scala-40c11466e6235b6834093b79b12fb5e2bf7807f9.tar.gz scala-40c11466e6235b6834093b79b12fb5e2bf7807f9.tar.bz2 scala-40c11466e6235b6834093b79b12fb5e2bf7807f9.zip |
Optimiser-friendly changes to Range for more ef...
Optimiser-friendly changes to Range for more efficient loops.
-rw-r--r-- | src/library/scala/Range.scala | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/library/scala/Range.scala b/src/library/scala/Range.scala index 8a6ba86bff..dbd4f82f69 100644 --- a/src/library/scala/Range.scala +++ b/src/library/scala/Range.scala @@ -170,7 +170,7 @@ extends VectorView[Int, Vector[Int]] with RangeToString[Int] */ def by(step: Int): Range = new Range(start, end, step) - override def foreach[U](f: Int => U) { + final override def foreach[U](f: Int => U) { var i = start if (step > 0) { while (i < end) { @@ -192,7 +192,8 @@ extends VectorView[Int, Vector[Int]] with RangeToString[Int] else plen(end, start, -step) } - def apply(idx: Int): Int = { + @inline + final def apply(idx: Int): Int = { if (idx < 0 || idx >= length) throw new IndexOutOfBoundsException(idx.toString) start + idx * step } @@ -206,7 +207,7 @@ extends VectorView[Int, Vector[Int]] with RangeToString[Int] object Range { /** @deprecated use Range.inclusive instead */ - class Inclusive(start: Int, end0: Int, step: Int) + final class Inclusive(start: Int, end0: Int, step: Int) extends Range(start, if (step > 0) end0 + 1 else end0 - 1, step) { self => override def by(step: Int): Range = new Inclusive(start, end0, step) } |