actor: simplify empty ByteString instances (#29268)
* actor: simplify empty ByteString instances * use Array.emptyByteArray
This commit is contained in:
parent
b95c82e63b
commit
08869ef7c6
2 changed files with 8 additions and 6 deletions
|
|
@ -0,0 +1,2 @@
|
||||||
|
# removed private auxiliary constructor
|
||||||
|
ProblemFilters.exclude[DirectMissingMethodProblem]("akka.util.ByteString#ByteString1.this")
|
||||||
|
|
@ -142,10 +142,10 @@ object ByteString {
|
||||||
*/
|
*/
|
||||||
def fromByteBuffer(buffer: ByteBuffer): ByteString = apply(buffer)
|
def fromByteBuffer(buffer: ByteBuffer): ByteString = apply(buffer)
|
||||||
|
|
||||||
val empty: ByteString = CompactByteString(Array.empty[Byte])
|
def empty: ByteString = ByteString1C.empty
|
||||||
|
|
||||||
/** Java API */
|
/** Java API */
|
||||||
val emptyByteString: ByteString = empty
|
def emptyByteString: ByteString = empty
|
||||||
|
|
||||||
def newBuilder: ByteStringBuilder = new ByteStringBuilder
|
def newBuilder: ByteStringBuilder = new ByteStringBuilder
|
||||||
|
|
||||||
|
|
@ -158,6 +158,8 @@ object ByteString {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
private[akka] object ByteString1C extends Companion {
|
private[akka] object ByteString1C extends Companion {
|
||||||
|
val empty = new ByteString1C(Array.emptyByteArray)
|
||||||
|
|
||||||
def fromString(s: String): ByteString1C = new ByteString1C(s.getBytes)
|
def fromString(s: String): ByteString1C = new ByteString1C(s.getBytes)
|
||||||
def apply(bytes: Array[Byte]): ByteString1C = new ByteString1C(bytes)
|
def apply(bytes: Array[Byte]): ByteString1C = new ByteString1C(bytes)
|
||||||
val SerializationIdentity = 1.toByte
|
val SerializationIdentity = 1.toByte
|
||||||
|
|
@ -273,7 +275,7 @@ object ByteString {
|
||||||
|
|
||||||
/** INTERNAL API: ByteString backed by exactly one array, with start / end markers */
|
/** INTERNAL API: ByteString backed by exactly one array, with start / end markers */
|
||||||
private[akka] object ByteString1 extends Companion {
|
private[akka] object ByteString1 extends Companion {
|
||||||
val empty: ByteString1 = new ByteString1(Array.empty[Byte])
|
val empty: ByteString1 = new ByteString1(Array.emptyByteArray, 0, 0)
|
||||||
def fromString(s: String): ByteString1 = apply(s.getBytes)
|
def fromString(s: String): ByteString1 = apply(s.getBytes)
|
||||||
def apply(bytes: Array[Byte]): ByteString1 = apply(bytes, 0, bytes.length)
|
def apply(bytes: Array[Byte]): ByteString1 = apply(bytes, 0, bytes.length)
|
||||||
def apply(bytes: Array[Byte], startIndex: Int, length: Int): ByteString1 =
|
def apply(bytes: Array[Byte], startIndex: Int, length: Int): ByteString1 =
|
||||||
|
|
@ -293,8 +295,6 @@ object ByteString {
|
||||||
extends ByteString
|
extends ByteString
|
||||||
with Serializable {
|
with Serializable {
|
||||||
|
|
||||||
private def this(bytes: Array[Byte]) = this(bytes, 0, bytes.length)
|
|
||||||
|
|
||||||
def apply(idx: Int): Byte = bytes(checkRangeConvert(idx))
|
def apply(idx: Int): Byte = bytes(checkRangeConvert(idx))
|
||||||
|
|
||||||
// Avoid `iterator` in performance sensitive code, call ops directly on ByteString instead
|
// Avoid `iterator` in performance sensitive code, call ops directly on ByteString instead
|
||||||
|
|
@ -1024,7 +1024,7 @@ object CompactByteString {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val empty: CompactByteString = ByteString.ByteString1C(Array.empty[Byte])
|
def empty: CompactByteString = ByteString.ByteString1C.empty
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue