Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c8a7789

Browse filesBrowse files
lundibundiMylesBorins
authored andcommitted
http2: avoid unnecessary buffer resize
Refs: #34315 Refs: #30351 PR-URL: #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>
1 parent b644ab6 commit c8a7789
Copy full SHA for c8a7789

File tree

Expand file treeCollapse file tree

1 file changed

+4
-3
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+4
-3
lines changed
Open diff view settings
Collapse file

‎src/node_http2.cc‎

Copy file name to clipboardExpand all lines: src/node_http2.cc
+4-3Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1841,7 +1841,10 @@ void Http2Session::OnStreamRead(ssize_t nread, const uv_buf_t& buf_) {
18411841

18421842
statistics_.data_received += nread;
18431843

1844-
if (UNLIKELY(stream_buf_offset_ > 0)) {
1844+
if (LIKELY(stream_buf_offset_ == 0)) {
1845+
// Shrink to the actual amount of used data.
1846+
buf.Resize(nread);
1847+
} else {
18451848
// This is a very unlikely case, and should only happen if the ReadStart()
18461849
// call in OnStreamAfterWrite() immediately provides data. If that does
18471850
// happen, we concatenate the data we received with the already-stored
@@ -1861,8 +1864,6 @@ void Http2Session::OnStreamRead(ssize_t nread, const uv_buf_t& buf_) {
18611864
DecrementCurrentSessionMemory(stream_buf_.len);
18621865
}
18631866

1864-
// Shrink to the actual amount of used data.
1865-
buf.Resize(nread);
18661867
IncrementCurrentSessionMemory(nread);
18671868

18681869
// Remember the current buffer, so that OnDataChunkReceived knows the

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.