Commit 7e34874b2bd1
tarball1 file changed+6-11
@@ -213,17 +213,12 @@ const POOL_IDLE: Duration = Duration::from_secs(2);
213213
/// Frees pooled staging buffers that have sat unused for [`POOL_IDLE`].214214
pub(crate) fn trim_staging(shared: &Shared) {215215
let now = Instant::now();216
- let expired: Vec<Pooled> = {217
- let mut pool = shared218
- .staging_pool219
- .lock()220
- .unwrap_or_else(|e| e.into_inner());221
- let (stale, kept) = std::mem::take(&mut *pool)222
- .into_iter()223
- .partition(|p| now - p.returned >= POOL_IDLE);224
- *pool = kept;225
- stale226
- };216
+ let expired: Vec<Pooled> = shared217
+ .staging_pool218
+ .lock()219
+ .unwrap_or_else(|e| e.into_inner())220
+ .extract_if(.., |p| now - p.returned >= POOL_IDLE)221
+ .collect();227222
if expired.is_empty() {228223
return;229224
}