Guard trace! behind cfg!(debug_assertions)
Even if the trace log level is disabled, the presence of the trace! macro still has a significant impact on performance because it is present in the inner loops of the allocator. Removing the trace! calls at compile-time reduces instruction count by ~7%.
This commit is contained in:
10
src/lib.rs
10
src/lib.rs
@@ -12,6 +12,16 @@
|
||||
|
||||
#![allow(dead_code)]
|
||||
|
||||
// Even when trace logging is disabled, the trace macro has a significant
|
||||
// performance cost so we disable it in release builds.
|
||||
macro_rules! trace {
|
||||
($($tt:tt)*) => {
|
||||
if cfg!(debug_assertions) {
|
||||
::log::trace!($($tt)*);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
pub(crate) mod cfg;
|
||||
pub(crate) mod domtree;
|
||||
pub mod indexset;
|
||||
|
||||
Reference in New Issue
Block a user