Make dump_{alloc,allocs,local}() no-ops when tracing is disabled.
Because they traverse data structures and build up strings, which is wasted effort if those strings aren't printed. The patch also removes some now-unnecessary log_enabled! tests at call sites.
This commit is contained in:
parent
cc79420968
commit
2e4f66a86f
@ -749,9 +749,7 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if log_enabled!(::log::Level::Trace) {
|
|
||||||
self.dump_local(dest);
|
self.dump_local(dest);
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -1538,6 +1536,9 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M
|
|||||||
|
|
||||||
pub fn dump_local(&self, place: Place) {
|
pub fn dump_local(&self, place: Place) {
|
||||||
// Debug output
|
// Debug output
|
||||||
|
if !log_enabled!(::log::Level::Trace) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
match place {
|
match place {
|
||||||
Place::Local { frame, local } => {
|
Place::Local { frame, local } => {
|
||||||
let mut allocs = Vec::new();
|
let mut allocs = Vec::new();
|
||||||
|
@ -334,11 +334,17 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
|
|||||||
|
|
||||||
/// For debugging, print an allocation and all allocations it points to, recursively.
|
/// For debugging, print an allocation and all allocations it points to, recursively.
|
||||||
pub fn dump_alloc(&self, id: AllocId) {
|
pub fn dump_alloc(&self, id: AllocId) {
|
||||||
|
if !log_enabled!(::log::Level::Trace) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
self.dump_allocs(vec![id]);
|
self.dump_allocs(vec![id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// For debugging, print a list of allocations and all allocations they point to, recursively.
|
/// For debugging, print a list of allocations and all allocations they point to, recursively.
|
||||||
pub fn dump_allocs(&self, mut allocs: Vec<AllocId>) {
|
pub fn dump_allocs(&self, mut allocs: Vec<AllocId>) {
|
||||||
|
if !log_enabled!(::log::Level::Trace) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
use std::fmt::Write;
|
use std::fmt::Write;
|
||||||
allocs.sort();
|
allocs.sort();
|
||||||
allocs.dedup();
|
allocs.dedup();
|
||||||
|
@ -218,9 +218,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if log_enabled!(::log::Level::Trace) {
|
|
||||||
self.dump_local(place);
|
self.dump_local(place);
|
||||||
}
|
|
||||||
|
|
||||||
Ok(place)
|
Ok(place)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user