optimize to map and filter in the same step

This commit is contained in:
tahahawa 2025-04-11 17:13:19 -04:00 committed by taha
parent 9a1eac7c8a
commit 508ca3352d

View File

@ -53,10 +53,9 @@ pub async fn init<T: Topology + std::fmt::Debug + Send + Sync + 'static>(
let scores = maestro.scores();
let scores_read = scores.read().expect("Should be able to read scores");
let scores_read_vec: Vec<Box<dyn Score<T>>> =
scores_read.iter().map(|s| s.clone_box()).collect();
let filtered: Vec<&Box<dyn Score<T>>> = scores_read_vec
let filtered: Vec<Box<dyn Score<T>>> = scores_read
.iter()
.map(|s| s.clone_box())
.filter(|s| s.name().contains(&args.run))
.collect();