src: reserve shared_array_buffers capacity in Message::Deserialize · nodejs/node@6651596 · GitHub
Skip to content

Commit 6651596

Browse files
agape1225aduh95
authored andcommitted
src: reserve shared_array_buffers capacity in Message::Deserialize
shared_array_buffers grows via repeated push_back() while iterating shared_array_buffers_, even though shared_array_buffers_.size() is already known before the loop starts and is an exact count of how many items will be pushed (one per iteration, unconditionally). This reserves capacity upfront to avoid the repeated allocate/copy/ free cycle that happens each time capacity is exceeded, mirroring the existing array_buffers.reserve() in the sibling Message::Serialize(). Signed-off-by: agape1225 <49804691+agape1225@users.noreply.github.com> PR-URL: #65304 Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 37b3db9 commit 6651596

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

‎src/node_messaging.cc‎

Lines changed: 1 addition & 0 deletions

0 commit comments

Comments
 (0)