Remove legancy code which we not need anymore as we use gathering writes anyway everywhere

This commit is contained in:
Norman Maurer 2013-09-01 11:00:20 +02:00
parent c149f4bcc0
commit 54d788f435

View File

@ -17,7 +17,6 @@ package io.netty.buffer;
import io.netty.util.ResourceLeak; import io.netty.util.ResourceLeak;
import io.netty.util.internal.EmptyArrays; import io.netty.util.internal.EmptyArrays;
import io.netty.util.internal.PlatformDependent;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@ -721,11 +720,6 @@ public class CompositeByteBuf extends AbstractReferenceCountedByteBuf {
@Override @Override
public int getBytes(int index, GatheringByteChannel out, int length) public int getBytes(int index, GatheringByteChannel out, int length)
throws IOException { throws IOException {
if (PlatformDependent.javaVersion() < 7) {
// XXX Gathering write is not supported because of a known issue.
// See http://bugs.sun.com/view_bug.do?bug_id=6210541
return out.write(copiedNioBuffer(index, length));
} else {
long writtenBytes = out.write(nioBuffers(index, length)); long writtenBytes = out.write(nioBuffers(index, length));
if (writtenBytes > Integer.MAX_VALUE) { if (writtenBytes > Integer.MAX_VALUE) {
return Integer.MAX_VALUE; return Integer.MAX_VALUE;
@ -733,7 +727,6 @@ public class CompositeByteBuf extends AbstractReferenceCountedByteBuf {
return (int) writtenBytes; return (int) writtenBytes;
} }
} }
}
@Override @Override
public CompositeByteBuf getBytes(int index, OutputStream out, int length) throws IOException { public CompositeByteBuf getBytes(int index, OutputStream out, int length) throws IOException {
@ -1115,21 +1108,6 @@ public class CompositeByteBuf extends AbstractReferenceCountedByteBuf {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
private ByteBuffer copiedNioBuffer(int index, int length) {
assert !freed;
if (components.size() == 1) {
return toNioBuffer(components.get(0).buf, index, length);
}
ByteBuffer[] buffers = nioBuffers(index, length);
ByteBuffer merged = ByteBuffer.allocate(length).order(order());
for (ByteBuffer b: buffers) {
merged.put(b);
}
merged.flip();
return merged;
}
@Override @Override
public ByteBuffer[] nioBuffers(int index, int length) { public ByteBuffer[] nioBuffers(int index, int length) {
checkIndex(index, length); checkIndex(index, length);
@ -1162,14 +1140,6 @@ public class CompositeByteBuf extends AbstractReferenceCountedByteBuf {
return buffers.toArray(new ByteBuffer[buffers.size()]); return buffers.toArray(new ByteBuffer[buffers.size()]);
} }
private static ByteBuffer toNioBuffer(ByteBuf buf, int index, int length) {
if (buf.nioBufferCount() == 1) {
return buf.nioBuffer(index, length);
} else {
return buf.copy(index, length).nioBuffer(0, length);
}
}
/** /**
* Consolidate the composed {@link ByteBuf}s * Consolidate the composed {@link ByteBuf}s
*/ */