@InternalApi(value="For internal usage only") public final class ZeroCopyByteStringUtil extends Object
ByteString
without copy.
Without this protobufs would force us to copy every single byte array out of the objects de-serialized from the wire (which already do one copy, on top of the copies the JVM does to go from kernel buffer to C buffer and from C buffer to JVM buffer).
For internal use only - public for technical reasons.
Constructor and Description |
---|
ZeroCopyByteStringUtil() |
Modifier and Type | Method and Description |
---|---|
static byte[] |
get(com.google.protobuf.ByteString byteString)
Extracts the byte array from the given
ByteString without copy. |
static com.google.protobuf.ByteString |
wrap(byte[] array)
Wraps a byte array in a
ByteString without copying it. |
public static com.google.protobuf.ByteString wrap(byte[] array)
ByteString
without copying it.array
- an array of byte.ByteString
object.public static byte[] get(com.google.protobuf.ByteString byteString)
ByteString
without copy.byteString
- A ByteString
from which to extract the array.