diff options
author | Josh Suereth <joshua.suereth@gmail.com> | 2012-05-08 21:53:25 -0400 |
---|---|---|
committer | Josh Suereth <joshua.suereth@gmail.com> | 2012-05-08 21:53:25 -0400 |
commit | 84764949e299329e476824c96fb250f72506bacd (patch) | |
tree | 86c9365cf1a95ad293e87ef5c731e169238ba477 /src/library | |
parent | da04d691c455aa3f3391bdbd9bac7fb59f29cedf (diff) | |
download | scala-84764949e299329e476824c96fb250f72506bacd.tar.gz scala-84764949e299329e476824c96fb250f72506bacd.tar.bz2 scala-84764949e299329e476824c96fb250f72506bacd.zip |
Fixes SI-5328. Iterator.patched failed when from=0.
It turns out iterator.patched forgot to drop replacement values if they were at the beginning.
This is because the index was advancing before checking to see if replaced elements should be
dropped. Moved this behavior to the beginning of next.
Diffstat (limited to 'src/library')
-rw-r--r-- | src/library/scala/collection/Iterator.scala | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/library/scala/collection/Iterator.scala b/src/library/scala/collection/Iterator.scala index e9a7906527..7d5cd9989c 100644 --- a/src/library/scala/collection/Iterator.scala +++ b/src/library/scala/collection/Iterator.scala @@ -1079,11 +1079,12 @@ trait Iterator[+A] extends TraversableOnce[A] { if (i < from) origElems.hasNext else patchElems.hasNext || origElems.hasNext def next(): B = { + // We have to do this *first* just in case from = 0. + if (i == from) origElems = origElems drop replaced val result: B = if (i < from || !patchElems.hasNext) origElems.next() else patchElems.next() i += 1 - if (i == from) origElems = origElems drop replaced result } } |