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:
Amanieu d'Antras
2022-01-11 13:30:13 +00:00
parent 2d9d5dd82b
commit ee4de54240
11 changed files with 237 additions and 239 deletions

View File

@@ -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;