Skip to content

Commit cf0876f

Browse files
committed
tweak suggested by eddyb
1 parent 6261869 commit cf0876f

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/librustc_mir/transform/inline.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,16 @@ impl Inliner<'tcx> {
256256
}
257257

258258
if self.use_simple_heuristic {
259-
return callee_body.basic_blocks().len() == 1 && callee_body.basic_blocks()[BasicBlock::from_u32(0)].statements.len() < 10;
259+
use rustc::mir::StatementKind::*;
260+
261+
return callee_body.basic_blocks().len() == 1
262+
&& callee_body.basic_blocks()[BasicBlock::from_u32(0)]
263+
.statements
264+
.iter()
265+
.filter(|stmt| !matches!(stmt.kind, StorageLive(_) | StorageDead(_)))
266+
.take(5)
267+
.count()
268+
<= 4;
260269
}
261270

262271
let mut threshold = if hinted { HINT_THRESHOLD } else { DEFAULT_THRESHOLD };

0 commit comments

Comments
 (0)