a) If we're built with deny_sensitive_logging, elide the log_sensitive calls altogether.
As the logger is hidden behind a Box<dyn OakLogger>, the compiler can make no assumptions about which logger is in use and even when we build with deny_sensitive_logging, we format the debug strings only then to immediately throw them away.
This is the reason why the log crate has info! and friends macros: with a macro, you can check if logging is enabled, and only format the string if it is. We should consider implementing similar macros; but for now, let's see if using the same crate feature gets rid of all the CPU we're burning on string formatting.
b) When constructing the response, move the contents of the vector, don't clone it. Doing a move removes an unnecessary allocation and a copy.
a) If we're built with
deny_sensitive_logging
, elide thelog_sensitive
calls altogether.As the logger is hidden behind a
Box<dyn OakLogger>
, the compiler can make no assumptions about which logger is in use and even when we build withdeny_sensitive_logging
, we format the debug strings only then to immediately throw them away.This is the reason why the
log
crate hasinfo!
and friends macros: with a macro, you can check if logging is enabled, and only format the string if it is. We should consider implementing similar macros; but for now, let's see if using the same crate feature gets rid of all the CPU we're burning on string formatting.b) When constructing the response, move the contents of the vector, don't clone it. Doing a move removes an unnecessary allocation and a copy.