From ad63adde1552cef1f16b2d3ea8b75bfd658e9d81 Mon Sep 17 00:00:00 2001 From: agape1225 <49804691+agape1225@users.noreply.github.com> Date: Sat, 15 Aug 2026 21:04:51 +0900 Subject: [PATCH] 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> --- src/node_messaging.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/node_messaging.cc b/src/node_messaging.cc index f00ab803fef0..b821d74527c0 100644 --- a/src/node_messaging.cc +++ b/src/node_messaging.cc @@ -190,6 +190,7 @@ MaybeLocal Message::Deserialize(Environment* env, transferables_.clear(); LocalVector shared_array_buffers(env->isolate()); + shared_array_buffers.reserve(shared_array_buffers_.size()); // Attach all transferred SharedArrayBuffers to their new Isolate. for (uint32_t i = 0; i < shared_array_buffers_.size(); ++i) { Local sab =