ByteString.apply optimized for Byte
This commit is contained in:
parent
9ef8ea5ff5
commit
05e93e3f18
1 changed files with 6 additions and 0 deletions
|
|
@ -11,6 +11,12 @@ object ByteString {
|
|||
|
||||
def apply(bytes: Array[Byte]): ByteString = new ByteString(bytes.clone)
|
||||
|
||||
def apply(bytes: Byte*): ByteString = {
|
||||
val ar = new Array[Byte](bytes.size)
|
||||
bytes.copyToArray(ar)
|
||||
new ByteString(ar)
|
||||
}
|
||||
|
||||
def apply[T](bytes: T*)(implicit num: Integral[T]): ByteString =
|
||||
new ByteString(bytes.map(x ⇒ num.toInt(x).toByte)(collection.breakOut))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue