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: #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 authored and ruyadorno committed Aug 22, 2022
1 parent a3ac445 commit d2dce59
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 d2dce59

Please sign in to comment.