From 8d1637045b25ff1e3bdd575fb7f926d43873d28a Mon Sep 17 00:00:00 2001 From: agape1225 <49804691+agape1225@users.noreply.github.com> Date: Sat, 25 Jul 2026 17:47:00 +0900 Subject: [PATCH 1/2] src: reserve vector capacity in Message::Serialize The array_buffers vector's upper bound is known before the loop starts (transfer_list_v.length()), so reserve the capacity upfront to avoid unnecessary reallocations. 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 f00ab803fef089..cdccdd8ee6d5b7 100644 --- a/src/node_messaging.cc +++ b/src/node_messaging.cc @@ -486,6 +486,7 @@ Maybe Message::Serialize(Environment* env, delegate.serializer = &serializer; LocalVector array_buffers(env->isolate()); + array_buffers.reserve(transfer_list_v.length()); for (uint32_t i = 0; i < transfer_list_v.length(); ++i) { Local entry_val = transfer_list_v[i]; if (!entry_val->IsObject()) { From 403b55e5e0d05e9a39d6742cfe822f909cc6e9e2 Mon Sep 17 00:00:00 2001 From: agape1225 <49804691+agape1225@users.noreply.github.com> Date: Sat, 25 Jul 2026 17:47:04 +0900 Subject: [PATCH 2/2] dns: reserve vector capacity in ParseTxtReply The chunks vector's upper bound is known before the loop starts (str_count from ares_dns_rr_get_abin_cnt), so reserve the capacity upfront to avoid unnecessary reallocations. Signed-off-by: agape1225 <49804691+agape1225@users.noreply.github.com> --- src/cares_wrap.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cares_wrap.cc b/src/cares_wrap.cc index 7be1e176654b64..6f8e8d89034123 100644 --- a/src/cares_wrap.cc +++ b/src/cares_wrap.cc @@ -627,6 +627,7 @@ Maybe ParseTxtReply(Environment* env, // Each TXT record is a chunk consisting of one or more character-strings. LocalVector chunks(env->isolate()); size_t str_count = ares_dns_rr_get_abin_cnt(rr, ARES_RR_TXT_DATA); + chunks.reserve(str_count); for (size_t j = 0; j < str_count; j++) { size_t str_len = 0; const unsigned char* str =