Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions compiler/rustc_mir_transform/src/patch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ impl<'tcx> MirPatch<'tcx> {
self.new_blocks.len(),
body.basic_blocks.len()
);
let bbs = if self.term_patch_map.is_empty() && self.new_blocks.is_empty() {
let bbs = if self.term_patch_map.iter().all(Option::is_none) && self.new_blocks.is_empty() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so this small perf regression might be real because we're now iterating over all basic blocks here even if all are None 🤔

🤷 would still be fine with landing this, but we may also consider alternatives, e.g. I would kinda assume that the patch map will be mostly None all the time, so maybe something that's better with sparse entries would perform better here.

anyways, haven't looked much at the relevant code yet

body.basic_blocks.as_mut_preserves_cfg()
} else {
body.basic_blocks.as_mut()
Expand Down Expand Up @@ -273,8 +273,8 @@ impl<'tcx> MirPatch<'tcx> {
}
debug!("MirPatch: adding statement {:?} at loc {:?}+{}", stmt, loc, delta);
loc.statement_index += delta;
let source_info = Self::source_info_for_index(&body[loc.block], loc);
body[loc.block]
let source_info = Self::source_info_for_index(&bbs[loc.block], loc);
bbs[loc.block]
.statements
.insert(loc.statement_index, Statement::new(source_info, stmt));
delta += 1;
Expand Down
Loading