Simplify the process of getting the component
This commit is contained in:
parent
cb8c9767f6
commit
332a35f9ed
@ -582,15 +582,11 @@ public class CompositeByteBuf extends AbstractByteBuf {
|
|||||||
+ capacity());
|
+ capacity());
|
||||||
}
|
}
|
||||||
|
|
||||||
List<ByteBuf> components = decompose(index, 1);
|
int componentId = componentId(index);
|
||||||
switch (components.size()) {
|
|
||||||
case 0:
|
//Return the component byte buffer
|
||||||
return Unpooled.EMPTY_BUFFER;
|
return components[componentId].duplicate();
|
||||||
case 1:
|
|
||||||
return components.get(0);
|
|
||||||
default:
|
|
||||||
throw new IOException("Index " + index + " is part of " + components.size() + " buffers!");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user