From bdafdb1e659820212abae1b8d7e0a1b512eb9ec7 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Wed, 21 Sep 2022 12:14:00 +0200 Subject: [PATCH] Use std::swap() to exchange elaboration_work_list Rather than moving one item at a time form the elaboration_work_list to the temporary queue use std::swap to exchange them all at once. This is a bit more efficient. Signed-off-by: Lars-Peter Clausen --- elaborate.cc | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/elaborate.cc b/elaborate.cc index 8a9fb2514..6e9cc3cdc 100644 --- a/elaborate.cc +++ b/elaborate.cc @@ -7215,10 +7215,7 @@ Design* elaborate(listroots) // Transfer the queue to a temporary queue. list cur_queue; - while (! des->elaboration_work_list.empty()) { - cur_queue.push_back(des->elaboration_work_list.front()); - des->elaboration_work_list.pop_front(); - } + std::swap(cur_queue, des->elaboration_work_list); // Run from the temporary queue. If the temporary queue // items create new work queue items, they will show up