Skip to content

Commit 21644c5

Browse files
authored
Avoid generating the state in the check if logging is disabled (#151)
This significantly improves the performance of the checker when trace logging is not enabled.
1 parent b89f441 commit 21644c5

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/checker.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,6 +1010,9 @@ impl<'a, F: Function> Checker<'a, F> {
10101010

10111011
trace!("=== CHECKER RESULT ===");
10121012
fn print_state(state: &CheckerState) {
1013+
if !trace_enabled!() {
1014+
return;
1015+
}
10131016
if let CheckerState::Allocations(allocs) = state {
10141017
let mut s = vec![];
10151018
for (alloc, state) in allocs {

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ macro_rules! trace {
3030

3131
macro_rules! trace_enabled {
3232
() => {
33-
cfg!(feature = "trace-log")
33+
cfg!(feature = "trace-log") && ::log::log_enabled!(::log::Level::Trace)
3434
};
3535
}
3636

0 commit comments

Comments
 (0)