Improved MultiByteArrayIterator.toByteString
MultiByteArrayIterator.toByteString now returns the optimal ByteString representation for the data.
This commit is contained in:
parent
0aff0ff101
commit
151b74262e
1 changed files with 6 additions and 3 deletions
|
|
@ -312,10 +312,13 @@ object ByteIterator {
|
||||||
}
|
}
|
||||||
|
|
||||||
final override def toByteString: ByteString = {
|
final override def toByteString: ByteString = {
|
||||||
|
if (iterators.tail isEmpty) iterators.head.toByteString
|
||||||
|
else {
|
||||||
val result = iterators.foldLeft(ByteString.empty) { _ ++ _.toByteString }
|
val result = iterators.foldLeft(ByteString.empty) { _ ++ _.toByteString }
|
||||||
clear()
|
clear()
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@tailrec protected final def getToArray[A](xs: Array[A], offset: Int, n: Int, elemSize: Int)(getSingle: ⇒ A)(getMult: (Array[A], Int, Int) ⇒ Unit): this.type = if (n <= 0) this else {
|
@tailrec protected final def getToArray[A](xs: Array[A], offset: Int, n: Int, elemSize: Int)(getSingle: ⇒ A)(getMult: (Array[A], Int, Int) ⇒ Unit): this.type = if (n <= 0) this else {
|
||||||
if (isEmpty) Iterator.empty.next
|
if (isEmpty) Iterator.empty.next
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue