Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Otrishko <shishugi@gmail.com>2020-07-22 19:18:28 +0300
committerMatteo Collina <hello@matteocollina.com>2020-07-27 16:41:41 +0300
commit62198d2d17002246e317558d0fcb6342cd07135b (patch)
treec3ce82cc85b123353b997588308512e8f70714c5 /src/node_http2.cc
parent3e6b05e1aaeee8213f738450364acebf4b92128d (diff)
http2: avoid unnecessary buffer resize
Refs: https://github.com/nodejs/node/pull/34315 Refs: https://github.com/nodejs/node/pull/30351 PR-URL: https://github.com/nodejs/node/pull/34480 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: David Carlier <devnexen@gmail.com>
Diffstat (limited to 'src/node_http2.cc')
-rw-r--r--src/node_http2.cc7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/node_http2.cc b/src/node_http2.cc
index 0d18ca15c19..670fa4802a4 100644
--- a/src/node_http2.cc
+++ b/src/node_http2.cc
@@ -1761,7 +1761,10 @@ void Http2Session::OnStreamRead(ssize_t nread, const uv_buf_t& buf_) {
statistics_.data_received += nread;
- if (UNLIKELY(stream_buf_offset_ > 0)) {
+ if (LIKELY(stream_buf_offset_ == 0)) {
+ // Shrink to the actual amount of used data.
+ buf.Resize(nread);
+ } else {
// This is a very unlikely case, and should only happen if the ReadStart()
// call in OnStreamAfterWrite() immediately provides data. If that does
// happen, we concatenate the data we received with the already-stored
@@ -1782,8 +1785,6 @@ void Http2Session::OnStreamRead(ssize_t nread, const uv_buf_t& buf_) {
DecrementCurrentSessionMemory(stream_buf_.len);
}
- // Shrink to the actual amount of used data.
- buf.Resize(nread);
IncrementCurrentSessionMemory(nread);
// Remember the current buffer, so that OnDataChunkReceived knows the