Prevent allocations caused by Logger::log_trace

C++ would always construct an `std::string` from the string constant
every iteration. Since this also happened when `YABRIDGE_DEBUG_LEVEL` is
not set to 2, this ended up causing unnecessary allocations.
This commit is contained in:
Robbert van der Helm
2021-05-23 00:21:21 +02:00
parent cf2fbf602c
commit df93944f3b
6 changed files with 40 additions and 36 deletions
+8 -7
View File
@@ -35,13 +35,6 @@ class Vst3Logger {
*/
inline void log(const std::string& message) { logger.log(message); }
/**
* @see Logger::log_trace
*/
inline void log_trace(const std::string& message) {
logger.log_trace(message);
}
/**
* Log calls to `FUnknown::queryInterface`. This will separately log about
* successful queries, queries for interfaces the object did not implement,
@@ -340,6 +333,14 @@ class Vst3Logger {
});
}
/**
* @see Logger::log_trace
*/
template <invocable_returning<std::string> F>
inline void log_trace(F&& fn) {
logger.log_trace(std::forward<F>(fn));
}
Logger& logger;
private: