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 <rlau@redhat.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
Tobias Nießen authored and Ruy Adorno committed 2022-08-22 19:37:28 -04:00
1 parent a3ac445198
commit d2dce59729
1 file changed
+1 -1
+1 -1
View File
@@ -349,7 +349,7 @@ class SerializerDelegate : public ValueSerializer::Delegate {
std::vector<BaseObjectPtr<BaseObject>> nested_transferables;
if (!host_objects_[i]->NestedTransferables().To(&nested_transferables))
return Nothing<bool>();
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()) {