diff options
author | Joakim Erdfelt | 2012-07-18 18:35:47 +0000 |
---|---|---|
committer | Joakim Erdfelt | 2012-07-18 18:35:47 +0000 |
commit | 85d7f9712a0619b3b9537fbbd266abd8bb9f9e5c (patch) | |
tree | ac4a7adca82b5cc42172ed59de2095b9e1237677 /jetty-util | |
parent | 21ef1570c7d35bf3b229a1248c24dd5cd7497920 (diff) | |
download | org.eclipse.jetty.project-85d7f9712a0619b3b9537fbbd266abd8bb9f9e5c.tar.gz org.eclipse.jetty.project-85d7f9712a0619b3b9537fbbd266abd8bb9f9e5c.tar.xz org.eclipse.jetty.project-85d7f9712a0619b3b9537fbbd266abd8bb9f9e5c.zip |
Making use of ByteBuffer.wrap() instead
Diffstat (limited to 'jetty-util')
-rw-r--r-- | jetty-util/src/main/java/org/eclipse/jetty/util/BufferUtil.java | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/BufferUtil.java b/jetty-util/src/main/java/org/eclipse/jetty/util/BufferUtil.java index 8ad221812e..96627ed225 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/BufferUtil.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/BufferUtil.java @@ -651,40 +651,31 @@ public class BufferUtil } /** - * Create a new ByteBuffer using a copy of the provided byte array. + * Create a new ByteBuffer using provided byte array. * * @param array - * the byte array to copy. (not using as-is in underlying implementation) + * the byte array to back buffer with. * @return ByteBuffer with provided byte array, in flush mode */ public static ByteBuffer toBuffer(byte array[]) { - int len = array.length; - ByteBuffer buf = ByteBuffer.allocate(len); - BufferUtil.clearToFill(buf); - buf.put(array,0,len); - BufferUtil.flipToFlush(buf,0); - return buf; + return ByteBuffer.wrap(array); } /** - * Create a new ByteBuffer using a copy of the provided byte array. + * Create a new ByteBuffer using the provided byte array. * * @param array - * the byte array to copy. (not using as-is in underlying implementation) + * the byte array to use. * @param offset - * the offset within the byte array to copy from + * the offset within the byte array to use from * @param length - * the length in bytes of the array to copy + * the length in bytes of the array to use * @return ByteBuffer with provided byte array, in flush mode */ public static ByteBuffer toBuffer(byte array[], int offset, int length) { - ByteBuffer buf = ByteBuffer.allocate(length); - BufferUtil.clearToFill(buf); - buf.put(array,offset,length); - BufferUtil.flipToFlush(buf,0); - return buf; + return ByteBuffer.wrap(array,offset,length); } public static ByteBuffer toBuffer(File file) throws IOException |