From 4090b9d9508459e0a43546fd7a37b5019ac3ef53 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] 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 eb7d1079f673..543c7507f165 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 =