Skip to content

Commit

Permalink
Use unordered_set
Browse files Browse the repository at this point in the history
Signed-off-by: Aaron Chong <[email protected]>
  • Loading branch information
aaronchongth committed Sep 18, 2023
1 parent 6bd66f7 commit 9a6735d
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions rmf_fleet_adapter/src/rmf_fleet_adapter/TaskManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -923,23 +923,21 @@ void TaskManager::set_queue(

// Cancel pending automatic tasks that will be removed from the new
// assignments.
std::vector<std::string> new_automatic_task_ids;
std::unordered_set<std::string> new_automatic_task_ids;
const std::vector<std::string> cancellation_labels =
{"New task assignments received."};
for (const auto& a : assignments)
{
if (a.request()->booking()->automatic())
{
new_automatic_task_ids.push_back(a.request()->booking()->id());
new_automatic_task_ids.insert(a.request()->booking()->id());
}
}
for (const auto& a : _queue)
{
if (a.request()->booking()->automatic() &&
std::find(
new_automatic_task_ids.begin(),
new_automatic_task_ids.end(),
a.request()->booking()->id()) == new_automatic_task_ids.end())
new_automatic_task_ids.find(a.request()->booking()->id()) ==
new_automatic_task_ids.end())
{
_publish_canceled_pending_task(a, cancellation_labels);
}
Expand Down

0 comments on commit 9a6735d

Please sign in to comment.