From d2dce597295aefee9cef8ab36c81e1174227fe32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Thu, 18 Aug 2022 21:22:47 +0200 Subject: [PATCH] src: avoid copying BaseObjectPtrs in loop While copying BaseObjectPtrs is cheap, it is not a no-op, so it is best to iterate over references to BaseObjectPtrs only. PR-URL: https://github.com/nodejs/node/pull/44270 Reviewed-By: Richard Lau Reviewed-By: Darshan Sen Reviewed-By: Luigi Pinca --- src/node_messaging.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node_messaging.cc b/src/node_messaging.cc index 58cd1882dd2c06..f88270fc75de91 100644 --- a/src/node_messaging.cc +++ b/src/node_messaging.cc @@ -349,7 +349,7 @@ class SerializerDelegate : public ValueSerializer::Delegate { std::vector> nested_transferables; if (!host_objects_[i]->NestedTransferables().To(&nested_transferables)) return Nothing(); - for (auto nested_transferable : nested_transferables) { + for (auto& nested_transferable : nested_transferables) { if (std::find(host_objects_.begin(), host_objects_.end(), nested_transferable) == host_objects_.end()) {