[
https://issues.apache.org/jira/browse/HTTPCORE-518?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16402238#comment-16402238
]
Oleg Kalnichevski commented on HTTPCORE-518:
--------------------------------------------
Sounds reasonable. Please raise a PR at GitHub.
Oleg
> Improve buffer allocation
> -------------------------
>
> Key: HTTPCORE-518
> URL: https://issues.apache.org/jira/browse/HTTPCORE-518
> Project: HttpComponents HttpCore
> Issue Type: Improvement
> Components: HttpCore NIO
> Reporter: Ion Moldovan
> Priority: Minor
>
> The doubling of the buffer size every time it exceeds its previous size is a
> good way for small buffers, but quite wasteful for large sizes.
> A more modest growth (e.g. 1.25 x Previous Size) when sizes are > 32MB would
> be a nice improvement.
> Proposed solution:
> {code:java}
> /**
> * Expands buffer's capacity.
> *
> * @throws BufferOverflowException in case we get over the maximum allowed
> value
> */
> protected void expand() throws BufferOverflowException {
> int newcapacity;
> if (this.buffer.capacity() <= (32 << 20) ) {
> newcapacity = (this.buffer.capacity() + 1) << 1;
> } else {
> newcapacity = (this.buffer.capacity() + 1) * 5 / 4;
> }
> ...
> }
> {code}
> What do you think?
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]