diff options
author | Denys Otrishko <shishugi@gmail.com> | 2019-11-10 15:22:46 +0300 |
---|---|---|
committer | Michaƫl Zasso <targos@protonmail.com> | 2019-12-09 12:23:09 +0300 |
commit | 3840abed11b682e1a70f6de1a1dba04bddae547a (patch) | |
tree | 86d86b8033f414e1eb83789d1af8a8e45ca93452 /src/node_http2.cc | |
parent | 43e947a15595cc5744c724c27b3585055e74f6bd (diff) |
http2: small clean up in OnStreamRead
PR-URL: https://github.com/nodejs/node/pull/30351
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/node_http2.cc')
-rw-r--r-- | src/node_http2.cc | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/node_http2.cc b/src/node_http2.cc index 9421c36f3be..2bcbcbe0784 100644 --- a/src/node_http2.cc +++ b/src/node_http2.cc @@ -1867,14 +1867,10 @@ void Http2Session::OnStreamRead(ssize_t nread, const uv_buf_t& buf_) { // call in OnStreamAfterWrite() immediately provides data. If that does // happen, we concatenate the data we received with the already-stored // pending input data, slicing off the already processed part. - AllocatedBuffer new_buf = env()->AllocateManaged( - stream_buf_.len - stream_buf_offset_ + nread); - memcpy(new_buf.data(), - stream_buf_.base + stream_buf_offset_, - stream_buf_.len - stream_buf_offset_); - memcpy(new_buf.data() + stream_buf_.len - stream_buf_offset_, - buf.data(), - nread); + size_t pending_len = stream_buf_.len - stream_buf_offset_; + AllocatedBuffer new_buf = env()->AllocateManaged(pending_len + nread); + memcpy(new_buf.data(), stream_buf_.base + stream_buf_offset_, pending_len); + memcpy(new_buf.data() + pending_len, buf.data(), nread); buf = std::move(new_buf); nread = buf.size(); stream_buf_offset_ = 0; |