Skip to content

Commit 91e0b46

Browse files
committed
coverage: Replace an unnecessary map with a set
This hashmap's values were never used.
1 parent 3b5b1aa commit 91e0b46

File tree

1 file changed

+7
-7
lines changed
  • compiler/rustc_mir_transform/src/coverage

1 file changed

+7
-7
lines changed

compiler/rustc_mir_transform/src/coverage/debug.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ use std::ops::Deref;
113113
use std::sync::OnceLock;
114114

115115
use itertools::Itertools;
116-
use rustc_data_structures::fx::FxHashMap;
116+
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
117117
use rustc_middle::mir::coverage::*;
118118
use rustc_middle::mir::create_dump_file;
119119
use rustc_middle::mir::generic_graphviz::GraphvizWriter;
@@ -488,7 +488,7 @@ pub(super) struct UsedExpressions {
488488

489489
#[derive(Default)]
490490
struct UsedExpressionsState {
491-
used_expression_operands: FxHashMap<Operand, Vec<ExpressionId>>,
491+
used_expression_operands: FxHashSet<Operand>,
492492
unused_expressions: Vec<(BcbCounter, Option<BasicCoverageBlock>, BasicCoverageBlock)>,
493493
}
494494

@@ -509,16 +509,16 @@ impl UsedExpressions {
509509
pub fn add_expression_operands(&mut self, expression: &BcbCounter) {
510510
let Some(state) = &mut self.state else { return };
511511

512-
if let BcbCounter::Expression { id, lhs, rhs, .. } = *expression {
513-
state.used_expression_operands.entry(lhs).or_insert_with(Vec::new).push(id);
514-
state.used_expression_operands.entry(rhs).or_insert_with(Vec::new).push(id);
512+
if let BcbCounter::Expression { lhs, rhs, .. } = *expression {
513+
state.used_expression_operands.insert(lhs);
514+
state.used_expression_operands.insert(rhs);
515515
}
516516
}
517517

518518
pub fn expression_is_used(&self, expression: &BcbCounter) -> bool {
519519
let Some(state) = &self.state else { return false };
520520

521-
state.used_expression_operands.contains_key(&expression.as_operand())
521+
state.used_expression_operands.contains(&expression.as_operand())
522522
}
523523

524524
pub fn add_unused_expression_if_not_found(
@@ -529,7 +529,7 @@ impl UsedExpressions {
529529
) {
530530
let Some(state) = &mut self.state else { return };
531531

532-
if !state.used_expression_operands.contains_key(&expression.as_operand()) {
532+
if !state.used_expression_operands.contains(&expression.as_operand()) {
533533
state.unused_expressions.push((expression.clone(), edge_from_bcb, target_bcb));
534534
}
535535
}

0 commit comments

Comments
 (0)