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,9 +312,12 @@ object ByteIterator {
|
|||
}
|
||||
|
||||
final override def toByteString: ByteString = {
|
||||
val result = iterators.foldLeft(ByteString.empty) { _ ++ _.toByteString }
|
||||
clear()
|
||||
result
|
||||
if (iterators.tail isEmpty) iterators.head.toByteString
|
||||
else {
|
||||
val result = iterators.foldLeft(ByteString.empty) { _ ++ _.toByteString }
|
||||
clear()
|
||||
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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue