Skip to content

Commit af0df14

Browse files
committed
Use bulk copy in PushBody.move
1 parent 65b742b commit af0df14

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

api/src/main/java/org/asynchttpclient/request/body/generator/FeedableBodyGenerator.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,15 @@ private void readBodyPart(ByteBuffer buffer, BodyPart part) {
120120
@Override
121121
public void close() {
122122
}
123-
124123
}
125124

126-
127125
private void move(ByteBuffer destination, ByteBuffer source) {
128-
while(destination.hasRemaining() && source.hasRemaining()) {
129-
destination.put(source.get());
126+
int size = Math.min(destination.remaining(), source.remaining());
127+
if (size > 0) {
128+
ByteBuffer slice = source.slice();
129+
slice.limit(size);
130+
destination.put(slice);
131+
source.position(source.position() + size);
130132
}
131133
}
132134

0 commit comments

Comments
 (0)