1
Fork 0

Don't allocate a local array at all if there are no locals

This commit is contained in:
Oliver Schneider 2018-03-23 10:47:55 +01:00
parent b18b776b8f
commit 4ea4dd23cd
No known key found for this signature in database
GPG key ID: A69F8D225B3AD7D9

View file

@ -383,6 +383,7 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M
) -> EvalResult<'tcx> {
::log_settings::settings().indentation += 1;
let locals = if mir.local_decls.len() > 1 {
let mut locals = IndexVec::from_elem(Some(Value::ByVal(PrimVal::Undef)), &mir.local_decls);
match self.tcx.describe_def(instance.def_id()) {
// statics and constants don't have `Storage*` statements, no need to look for them
@ -401,6 +402,11 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M
}
},
}
locals
} else {
// don't allocate at all for trivial constants
IndexVec::new()
};
self.stack.push(Frame {
mir,