Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimize number of buffer allocations #11879

Merged
merged 16 commits into from
Feb 14, 2025
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@
*/
class OkHttpWritableBufferAllocator implements WritableBufferAllocator {

// Use 4k as our minimum buffer size.
private static final int MIN_BUFFER = 4096;

// Set the maximum buffer size to 1MB
private static final int MAX_BUFFER = 1024 * 1024;

Expand All @@ -45,7 +42,7 @@ class OkHttpWritableBufferAllocator implements WritableBufferAllocator {
*/
@Override
public WritableBuffer allocate(int capacityHint) {
capacityHint = Math.min(MAX_BUFFER, Math.max(MIN_BUFFER, capacityHint));
capacityHint = Math.min(MAX_BUFFER, capacityHint);
return new OkHttpWritableBuffer(new Buffer(), capacityHint);
}
}