Added specialized implementation of foreach to MultiByteArrayIterator
This commit is contained in:
parent
76010d5b56
commit
9865a4e3e1
1 changed files with 7 additions and 2 deletions
|
|
@ -314,6 +314,11 @@ object ByteIterator {
|
||||||
normalize()
|
normalize()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override def foreach[@specialized U](f: Byte ⇒ U): Unit = {
|
||||||
|
iterators foreach { _ foreach f }
|
||||||
|
clear()
|
||||||
|
}
|
||||||
|
|
||||||
final override def toByteString: ByteString = {
|
final override def toByteString: ByteString = {
|
||||||
if (iterators.tail isEmpty) iterators.head.toByteString
|
if (iterators.tail isEmpty) iterators.head.toByteString
|
||||||
else {
|
else {
|
||||||
|
|
@ -474,12 +479,12 @@ abstract class ByteIterator extends BufferedIterator[Byte] {
|
||||||
|
|
||||||
override def toSeq: ByteString = toByteString
|
override def toSeq: ByteString = toByteString
|
||||||
|
|
||||||
@inline final override def foreach[@specialized U](f: Byte ⇒ U): Unit =
|
override def foreach[@specialized U](f: Byte ⇒ U): Unit =
|
||||||
while (hasNext) f(next())
|
while (hasNext) f(next())
|
||||||
|
|
||||||
final override def foldLeft[@specialized B](z: B)(op: (B, Byte) ⇒ B): B = {
|
final override def foldLeft[@specialized B](z: B)(op: (B, Byte) ⇒ B): B = {
|
||||||
var acc = z
|
var acc = z
|
||||||
while (hasNext) acc = op(acc, next())
|
foreach { byte ⇒ acc = op(acc, byte) }
|
||||||
acc
|
acc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue