1
Fork 0

Avoid generating QueryMap::extend for each key type

This commit is contained in:
Mark Rousskov 2021-05-01 17:53:34 -04:00
parent 1c2c6b6700
commit 61fd56fdb9

View file

@ -125,18 +125,15 @@ where
// We use try_lock_shards here since we are called from the // We use try_lock_shards here since we are called from the
// deadlock handler, and this shouldn't be locked. // deadlock handler, and this shouldn't be locked.
let shards = self.shards.try_lock_shards()?; let shards = self.shards.try_lock_shards()?;
let shards = shards.iter().enumerate(); for (shard_id, shard) in shards.iter().enumerate() {
jobs.extend(shards.flat_map(|(shard_id, shard)| { for (k, v) in shard.active.iter() {
shard.active.iter().filter_map(move |(k, v)| {
if let QueryResult::Started(ref job) = *v { if let QueryResult::Started(ref job) = *v {
let id = QueryJobId::new(job.id, shard_id, kind); let id = QueryJobId::new(job.id, shard_id, kind);
let info = QueryInfo { span: job.span, query: make_query(tcx, k.clone()) }; let info = QueryInfo { span: job.span, query: make_query(tcx, k.clone()) };
Some((id, QueryJobInfo { info, job: job.clone() })) jobs.insert(id, QueryJobInfo { info, job: job.clone() });
} else {
None
} }
}) }
})); }
Some(()) Some(())
} }