优化 GetTask 中 ByteArrayOutputStream 的初始大小 (#4209)
This commit is contained in:
@@ -60,9 +60,10 @@ public final class GetTask extends FetchTask<String> {
|
||||
|
||||
@Override
|
||||
protected Context getContext(URLConnection connection, boolean checkETag, String bmclapiHash) {
|
||||
return new Context() {
|
||||
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
int length = connection.getContentLength();
|
||||
final var baos = new ByteArrayOutputStream(length <= 0 ? 8192 : length);
|
||||
|
||||
return new Context() {
|
||||
@Override
|
||||
public void write(byte[] buffer, int offset, int len) {
|
||||
baos.write(buffer, offset, len);
|
||||
|
||||
Reference in New Issue
Block a user