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