Package com.google.protobuf
Interface ByteString.ByteArrayCopier
- All Known Implementing Classes:
ByteString.ArraysByteArrayCopier
,ByteString.SystemByteArrayCopier
- Enclosing class:
ByteString
private static interface ByteString.ByteArrayCopier
An interface to efficiently copy
byte[]
.
One of the noticeable costs of copying a byte[] into a new array using
System.arraycopy
is nullification of a new buffer before the copy. It has been shown the
Hotspot VM is capable to intrisicfy Arrays.copyOfRange
operation to avoid this
expensive nullification and provide substantial performance gain. Unfortunately this does not
hold on Android runtimes and could make the copy slightly slower due to additional code in the
Arrays.copyOfRange
. Thus we provide two different implementation for array copier for
Hotspot and Android runtimes.
-
Method Summary
Modifier and TypeMethodDescriptionbyte[]
copyFrom
(byte[] bytes, int offset, int size) Copies the specified range of the specified array into a new array
-
Method Details
-
copyFrom
byte[] copyFrom(byte[] bytes, int offset, int size) Copies the specified range of the specified array into a new array
-