Skip to content

Commit 56def28

Browse files
committed
Use HashMap::retain
Why didn't I use this before? It's been stable since 1.18...
1 parent ada4dc4 commit 56def28

File tree

2 files changed

+4
-14
lines changed

2 files changed

+4
-14
lines changed

compiler/base/orchestrator/src/coordinator.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2430,15 +2430,8 @@ impl Commander {
24302430
}
24312431

24322432
Gc => {
2433-
waiting = mem::take(&mut waiting)
2434-
.into_iter()
2435-
.filter(|(_job_id, tx)| !tx.is_closed())
2436-
.collect();
2437-
2438-
waiting_once = mem::take(&mut waiting_once)
2439-
.into_iter()
2440-
.filter(|(_job_id, tx)| !tx.is_closed())
2441-
.collect();
2433+
waiting.retain(|_job_id, tx| !tx.is_closed());
2434+
waiting_once.retain(|_job_id, tx| !tx.is_closed());
24422435
}
24432436
}
24442437
}

ui/src/server_axum/websocket.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use snafu::prelude::*;
1515
use std::{
1616
collections::BTreeMap,
1717
convert::TryFrom,
18-
mem,
1918
pin::pin,
2019
sync::{
2120
atomic::{AtomicU64, Ordering},
@@ -470,10 +469,8 @@ async fn handle_core(
470469
}
471470

472471
GarbageCollection => {
473-
active_executions = mem::take(&mut active_executions)
474-
.into_iter()
475-
.filter(|(_id, (_, tx))| tx.as_ref().is_some_and(|tx| !tx.is_closed()))
476-
.collect();
472+
active_executions
473+
.retain(|_id, (_, tx)| tx.as_ref().is_some_and(|tx| !tx.is_closed()));
477474
}
478475

479476
IdleTimeout | IdleRequest => {

0 commit comments

Comments
 (0)