Wrap debug output calls in gccrs to reduce compile time when disabled
gccrs optimizes compile times by wrapping debug output calls, preventing argument evaluation when debugging is off.
Compile times in gccrs are improved by refactoring debug output calls into a do-while wrapper. This change ensures that arguments to debug functions are only evaluated when debugging is actually enabled, preventing unnecessary computation and speeding up compilation when debug output is turned off. The changes affect rust-diagnostics.cc and rust-diagnostics.h.
In Details
This commit optimizes gccrs' debug output mechanism by introducing a do-while wrapper. Previously, arguments to rust_debug_loc might be evaluated even if debug output was disabled. The new rust_debug and updated rust_debug_loc wrappers ensure that the arguments are only evaluated when the DEBUG flag is active, effectively short-circuiting the evaluation and reducing compile-time overhead.
- do-while wrapper
- A programming construct where a block of code is executed at least once, followed by a conditional check. In this context, it's used to control the execution of debug logging statements.
- argument evaluation
- The process of computing the value of an argument passed to a function or macro before the function is called or the macro is expanded.