diff options
author | Paul Phillips <paulp@improving.org> | 2010-07-05 16:00:22 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-07-05 16:00:22 +0000 |
commit | 536cdd87befe905e791acdd5ff8b9dc7d27e8340 (patch) | |
tree | 4fe3b0513933758e87db90d1c816df25c68bfca9 /src/library | |
parent | b053d329d3f148d1b0afed92bcbd722c84aeeabd (diff) | |
download | scala-536cdd87befe905e791acdd5ff8b9dc7d27e8340.tar.gz scala-536cdd87befe905e791acdd5ff8b9dc7d27e8340.tar.bz2 scala-536cdd87befe905e791acdd5ff8b9dc7d27e8340.zip |
The take/drop methods in IndexedSeqOptimized we...
The take/drop methods in IndexedSeqOptimized were overridden to call
slice without checking bounds, causing it to fail when the argument is
too large. Restored expected behavior. No review.
Diffstat (limited to 'src/library')
-rwxr-xr-x | src/library/scala/collection/IndexedSeqOptimized.scala | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/library/scala/collection/IndexedSeqOptimized.scala b/src/library/scala/collection/IndexedSeqOptimized.scala index 6360de33f1..694d85bbb0 100755 --- a/src/library/scala/collection/IndexedSeqOptimized.scala +++ b/src/library/scala/collection/IndexedSeqOptimized.scala @@ -139,16 +139,16 @@ trait IndexedSeqOptimized[+A, +Repr] extends IndexedSeqLike[A, Repr] { self => def init: Repr = if (length > 0) slice(0, length - 1) else super.init override /*TraversableLike*/ - def take(n: Int): Repr = slice(0, n) + def take(n: Int): Repr = if (n < length) slice(0, n) else slice(0, length) override /*TraversableLike*/ - def drop(n: Int): Repr = slice(n, length) + def drop(n: Int): Repr = if (n < length) slice(n, length) else newBuilder.result override /*IterableLike*/ - def takeRight(n: Int): Repr = slice(length - n, length) + def takeRight(n: Int): Repr = if (n < length) slice(length - n, length) else slice(0, length) override /*IterableLike*/ - def dropRight(n: Int): Repr = slice(0, length - n) + def dropRight(n: Int): Repr = if (n < length) slice(0, length - n) else slice(0, length) override /*TraversableLike*/ def splitAt(n: Int): (Repr, Repr) = (take(n), drop(n)) |