From 332a35f9ed00e1d5631085729f30c45c6ea42ea0 Mon Sep 17 00:00:00 2001 From: Cruz Julian Bishop Date: Thu, 28 Jun 2012 10:29:11 +1000 Subject: [PATCH] Simplify the process of getting the component --- .../java/io/netty/buffer/CompositeByteBuf.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/buffer/src/main/java/io/netty/buffer/CompositeByteBuf.java b/buffer/src/main/java/io/netty/buffer/CompositeByteBuf.java index f9ecc34aa6..a703a8ad79 100644 --- a/buffer/src/main/java/io/netty/buffer/CompositeByteBuf.java +++ b/buffer/src/main/java/io/netty/buffer/CompositeByteBuf.java @@ -582,15 +582,11 @@ public class CompositeByteBuf extends AbstractByteBuf { + capacity()); } - List components = decompose(index, 1); - switch (components.size()) { - case 0: - return Unpooled.EMPTY_BUFFER; - case 1: - return components.get(0); - default: - throw new IOException("Index " + index + " is part of " + components.size() + " buffers!"); - } + int componentId = componentId(index); + + //Return the component byte buffer + return components[componentId].duplicate(); + } @Override