Skip to content

Commit

Permalink
src: avoid copying BaseObjectPtrs in loop
Browse files Browse the repository at this point in the history
While copying BaseObjectPtrs is cheap, it is not a no-op, so it is best
to iterate over references to BaseObjectPtrs only.

PR-URL: nodejs#44270
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
tniessen committed Aug 18, 2022
1 parent 4f1a9fc commit a2dcc08
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/node_messaging.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down

0 comments on commit a2dcc08

Please sign in to comment.