Skip to content

Commit cb56470

Browse files
committed
*: upgrade drain_filter
See rust-lang/rust/pull/104455 Signed-off-by: Neil Shen <[email protected]>
1 parent bb5f31e commit cb56470

File tree

9 files changed

+16
-17
lines changed

9 files changed

+16
-17
lines changed

components/engine_traits/src/flush.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ impl SstApplyState {
119119
for sst in ssts {
120120
let cf_index = data_cf_offset(sst.get_cf_name());
121121
if let Some(metas) = sst_list.get_mut(cf_index) {
122-
metas.drain_filter(|entry| entry.sst.get_uuid() == sst.get_uuid());
122+
metas.retain(|entry| entry.sst.get_uuid() != sst.get_uuid());
123123
}
124124
}
125125
}

components/engine_traits/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,6 @@
254254
#![feature(linked_list_cursors)]
255255
#![feature(let_chains)]
256256
#![feature(str_split_as_str)]
257-
#![feature(drain_filter)]
258257

259258
#[macro_use(fail_point)]
260259
extern crate fail;

components/raftstore/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#![feature(div_duration)]
66
#![feature(min_specialization)]
77
#![feature(box_patterns)]
8-
#![feature(hash_drain_filter)]
8+
#![feature(hash_extract_if)]
99
#![feature(let_chains)]
1010
#![feature(assert_matches)]
1111
#![feature(type_alias_impl_trait)]

components/raftstore/src/store/snap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2174,7 +2174,7 @@ impl TabletSnapManager {
21742174
.stats
21752175
.lock()
21762176
.unwrap()
2177-
.drain_filter(|_, (_, stat)| stat.get_region_id() > 0)
2177+
.extract_if(|_, (_, stat)| stat.get_region_id() > 0)
21782178
.map(|(_, (_, stat))| stat)
21792179
.filter(|stat| stat.get_total_duration_sec() > 1)
21802180
.collect();

components/raftstore/src/store/txn_ext.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ pub struct PeerPessimisticLocks {
8484
/// likely to be proposed successfully, while the leader will need at
8585
/// least another round to receive the transfer leader message from the
8686
/// transferee.
87-
///
87+
///
8888
/// - Split region The lock with the deleted mark SHOULD be moved to new
8989
/// regions on region split. Considering the following cases with
9090
/// different orders: 1. Propose write -> propose split -> apply write ->
@@ -244,7 +244,7 @@ impl PeerPessimisticLocks {
244244
// Locks that are marked deleted still need to be moved to the new regions,
245245
// and the deleted mark should also be cleared.
246246
// Refer to the comment in `PeerPessimisticLocks` for details.
247-
let removed_locks = self.map.drain_filter(|key, _| {
247+
let removed_locks = self.map.extract_if(|key, _| {
248248
let key = &**key.as_encoded();
249249
let (start_key, end_key) = (derived.get_start_key(), derived.get_end_key());
250250
key < start_key || (!end_key.is_empty() && key >= end_key)

components/resource_metering/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// TODO(mornyx): crate doc.
44

5-
#![feature(hash_drain_filter)]
5+
#![feature(hash_extract_if)]
66
#![feature(core_intrinsics)]
77

88
use std::{

components/resource_metering/src/model.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ impl RawRecords {
8787
pdqselect::select_by(&mut buf, k, |a, b| b.cmp(a));
8888
let kth = buf[k];
8989
// Evict records with cpu time less or equal than `kth`
90-
let evicted_records = self.records.drain_filter(|_, r| r.cpu_time <= kth);
90+
let evicted_records = self.records.extract_if(|_, r| r.cpu_time <= kth);
9191
// Record evicted into others
9292
for (_, record) in evicted_records {
9393
others.merge(&record);

src/config/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2064,7 +2064,7 @@ impl<T: ConfigurableDb + Send + Sync> ConfigManager for DbConfigManger<T> {
20642064
self.cfg.update(change.clone())?;
20652065
let change_str = format!("{:?}", change);
20662066
let mut change: Vec<(String, ConfigValue)> = change.into_iter().collect();
2067-
let cf_config = change.drain_filter(|(name, _)| name.ends_with("cf"));
2067+
let cf_config = change.extract_if(|(name, _)| name.ends_with("cf"));
20682068
for (cf_name, cf_change) in cf_config {
20692069
if let ConfigValue::Module(mut cf_change) = cf_change {
20702070
// defaultcf -> default
@@ -2098,7 +2098,7 @@ impl<T: ConfigurableDb + Send + Sync> ConfigManager for DbConfigManger<T> {
20982098
}
20992099

21002100
if let Some(rate_bytes_config) = change
2101-
.drain_filter(|(name, _)| name == "rate_bytes_per_sec")
2101+
.extract_if(|(name, _)| name == "rate_bytes_per_sec")
21022102
.next()
21032103
{
21042104
let rate_bytes_per_sec: ReadableSize = rate_bytes_config.1.into();
@@ -2107,7 +2107,7 @@ impl<T: ConfigurableDb + Send + Sync> ConfigManager for DbConfigManger<T> {
21072107
}
21082108

21092109
if let Some(rate_bytes_config) = change
2110-
.drain_filter(|(name, _)| name == "rate_limiter_auto_tuned")
2110+
.extract_if(|(name, _)| name == "rate_limiter_auto_tuned")
21112111
.next()
21122112
{
21132113
let rate_limiter_auto_tuned: bool = rate_bytes_config.1.into();
@@ -2116,30 +2116,30 @@ impl<T: ConfigurableDb + Send + Sync> ConfigManager for DbConfigManger<T> {
21162116
}
21172117

21182118
if let Some(size) = change
2119-
.drain_filter(|(name, _)| name == "write_buffer_limit")
2119+
.extract_if(|(name, _)| name == "write_buffer_limit")
21202120
.next()
21212121
{
21222122
let size: ReadableSize = size.1.into();
21232123
self.db.set_flush_size(size.0 as usize)?;
21242124
}
21252125

21262126
if let Some(f) = change
2127-
.drain_filter(|(name, _)| name == "write_buffer_flush_oldest_first")
2127+
.extract_if(|(name, _)| name == "write_buffer_flush_oldest_first")
21282128
.next()
21292129
{
21302130
self.db.set_flush_oldest_first(f.1.into())?;
21312131
}
21322132

21332133
if let Some(background_jobs_config) = change
2134-
.drain_filter(|(name, _)| name == "max_background_jobs")
2134+
.extract_if(|(name, _)| name == "max_background_jobs")
21352135
.next()
21362136
{
21372137
let max_background_jobs: i32 = background_jobs_config.1.into();
21382138
self.update_background_cfg(max_background_jobs, self.cfg.max_background_flushes)?;
21392139
}
21402140

21412141
if let Some(background_subcompactions_config) = change
2142-
.drain_filter(|(name, _)| name == "max_sub_compactions")
2142+
.extract_if(|(name, _)| name == "max_sub_compactions")
21432143
.next()
21442144
{
21452145
let max_subcompactions: u32 = background_subcompactions_config.1.into();
@@ -2148,7 +2148,7 @@ impl<T: ConfigurableDb + Send + Sync> ConfigManager for DbConfigManger<T> {
21482148
}
21492149

21502150
if let Some(background_flushes_config) = change
2151-
.drain_filter(|(name, _)| name == "max_background_flushes")
2151+
.extract_if(|(name, _)| name == "max_background_flushes")
21522152
.next()
21532153
{
21542154
let max_background_flushes: i32 = background_flushes_config.1.into();

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#![feature(proc_macro_hygiene)]
2424
#![feature(min_specialization)]
2525
#![feature(box_patterns)]
26-
#![feature(drain_filter)]
26+
#![feature(extract_if)]
2727
#![feature(deadline_api)]
2828
#![feature(let_chains)]
2929
#![feature(read_buf)]

0 commit comments

Comments
 (0)