@@ -8,18 +8,13 @@ namespace node {
88std::vector<CleanupQueue::CleanupHookCallback> CleanupQueue::GetOrdered ()
99 const {
1010 // Copy into a vector, since we can't sort an unordered_set in-place.
11- std::vector<CleanupHookCallback> callbacks (cleanup_hooks_.begin (),
12- cleanup_hooks_.end ());
11+ std::vector callbacks (cleanup_hooks_.begin (), cleanup_hooks_.end ());
1312 // We can't erase the copied elements from `cleanup_hooks_` yet, because we
1413 // need to be able to check whether they were un-scheduled by another hook.
1514
16- std::sort (callbacks.begin (),
17- callbacks.end (),
18- [](const CleanupHookCallback& a, const CleanupHookCallback& b) {
19- // Sort in descending order so that the most recently inserted
20- // callbacks are run first.
21- return a.insertion_order_counter_ > b.insertion_order_counter_ ;
22- });
15+ // Sort in descending order so that the most recently inserted callbacks are
16+ // run first.
17+ std::ranges::sort (callbacks, std::greater ());
2318
2419 return callbacks;
2520}
@@ -28,7 +23,7 @@ void CleanupQueue::Drain() {
2823 std::vector<CleanupHookCallback> callbacks = GetOrdered ();
2924
3025 for (const CleanupHookCallback& cb : callbacks) {
31- if (cleanup_hooks_.count (cb) == 0 ) {
26+ if (! cleanup_hooks_.contains (cb)) {
3227 // This hook was removed from the `cleanup_hooks_` set during another
3328 // hook that was run earlier. Nothing to do here.
3429 continue ;
0 commit comments