remove redundant vector instantiation, replace with erase-remove idiom
This commit is contained in:
parent
10ce7a3bd6
commit
ff9b492041
3 changed files with 17 additions and 30 deletions
|
@ -52,7 +52,7 @@ public:
|
||||||
virtual void clear_active_entities() = 0;
|
virtual void clear_active_entities() = 0;
|
||||||
|
|
||||||
virtual void clear_handles() = 0;
|
virtual void clear_handles() = 0;
|
||||||
virtual void revalidate_handles() = 0;
|
virtual void remove_null_handles() = 0;
|
||||||
virtual bool collect_entities(const WeakNodeVector & weak_nodes) = 0;
|
virtual bool collect_entities(const WeakNodeVector & weak_nodes) = 0;
|
||||||
|
|
||||||
/// Provide a newly initialized AnyExecutable object.
|
/// Provide a newly initialized AnyExecutable object.
|
||||||
|
|
|
@ -108,35 +108,22 @@ public:
|
||||||
client_handles_.clear();
|
client_handles_.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void revalidate_handles()
|
void remove_null_handles()
|
||||||
{
|
{
|
||||||
{
|
subscriber_handles_.erase(
|
||||||
VectorRebind<void *> temp;
|
std::remove(subscriber_handles_.begin(), subscriber_handles_.end(), nullptr),
|
||||||
for (auto & subscriber_handle : subscriber_handles_) {
|
subscriber_handles_.end()
|
||||||
if (subscriber_handle) {
|
);
|
||||||
temp.push_back(subscriber_handle);
|
|
||||||
}
|
service_handles_.erase(
|
||||||
}
|
std::remove(service_handles_.begin(), service_handles_.end(), nullptr),
|
||||||
subscriber_handles_.swap(temp);
|
service_handles_.end()
|
||||||
}
|
);
|
||||||
{
|
|
||||||
VectorRebind<void *> temp;
|
client_handles_.erase(
|
||||||
for (auto & service_handle : service_handles_) {
|
std::remove(client_handles_.begin(), client_handles_.end(), nullptr),
|
||||||
if (service_handle) {
|
client_handles_.end()
|
||||||
temp.push_back(service_handle);
|
);
|
||||||
}
|
|
||||||
}
|
|
||||||
service_handles_.swap(temp);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
VectorRebind<void *> temp;
|
|
||||||
for (auto & client_handle : client_handles_) {
|
|
||||||
if (client_handle) {
|
|
||||||
temp.push_back(client_handle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
client_handles_.swap(temp);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool collect_entities(const WeakNodeVector & weak_nodes)
|
bool collect_entities(const WeakNodeVector & weak_nodes)
|
||||||
|
|
|
@ -379,7 +379,7 @@ Executor::wait_for_work(std::chrono::nanoseconds timeout)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
memory_strategy_->revalidate_handles();
|
memory_strategy_->remove_null_handles();
|
||||||
}
|
}
|
||||||
|
|
||||||
rclcpp::node::Node::SharedPtr
|
rclcpp::node::Node::SharedPtr
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue