From 546797f2b1f5b2a95c05a34fb007bd06c201df8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Wed, 28 Jun 2023 13:52:45 +0200 Subject: [PATCH] quic: prevent copying ngtcp2_cid The existing code explicitly uses the CID(const ngtcp2_cid*) constructor that does not copy the given ngtcp2_cid, but the range-based for loop still unnecessarily copies the ngtcp2_cid. Use auto& to avoid copying. PR-URL: https://github.com/nodejs/node/pull/48561 Reviewed-By: Luigi Pinca Reviewed-By: Mohammed Keyvanzadeh --- src/quic/session.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/quic/session.cc b/src/quic/session.cc index a6204f8da1b434..87a4a8e54557f7 100644 --- a/src/quic/session.cc +++ b/src/quic/session.cc @@ -643,7 +643,7 @@ void Session::Destroy() { endpoint_->DisassociateCID(config_.dcid); endpoint_->DisassociateCID(config_.preferred_address_cid); - for (auto cid : cids) endpoint_->DisassociateCID(CID(&cid)); + for (const auto& cid : cids) endpoint_->DisassociateCID(CID(&cid)); for (const auto& token : tokens) { if (token.token_present)