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 juanarbol committed Oct 11, 2022
1 parent fdb699c commit 8195c81
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/node_messaging.cc
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 8195c81

Please sign in to comment.