mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-06-17 08:53:56 +02:00
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:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user