mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-07 12:10:09 +02:00
Prevent allocations in Vst3Logger::log_query_interface
String constants will be converted to `std::string` because it's not constexpr yet, and that will allocate for longer strings. Since this function only prints something when `YABRIDGE_DEBUG_LEVEL` is set to 2 or higher that seems like a waste.
This commit is contained in:
@@ -54,7 +54,7 @@ std::string format_bstream(const YaBStream& stream) {
|
||||
Vst3Logger::Vst3Logger(Logger& generic_logger) : logger(generic_logger) {}
|
||||
|
||||
void Vst3Logger::log_query_interface(
|
||||
const std::string& where,
|
||||
const char* where,
|
||||
tresult result,
|
||||
const std::optional<Steinberg::FUID>& uid) {
|
||||
if (logger.verbosity >= Logger::Verbosity::all_events) [[unlikely]] {
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include <boost/container/string.hpp>
|
||||
|
||||
#include "../serialization/vst3.h"
|
||||
#include "common.h"
|
||||
|
||||
@@ -41,8 +43,14 @@ class Vst3Logger {
|
||||
* and queries for interfaces we do not implement depending on the verbosity
|
||||
* level. In case we could not get a FUID (because of null pointers, for
|
||||
* instance), `std::nullopt` should be passed.
|
||||
*
|
||||
* NOTE: We're passing a `const char*` here instead of a `const
|
||||
* std::string&` because that will still allocate for longer strings
|
||||
* because `std::string` isn't constexpr yet. Most calls to this
|
||||
* function won't print anything, so we should make sure that calling
|
||||
* it doesn't add unnecessary overhead.
|
||||
*/
|
||||
void log_query_interface(const std::string& where,
|
||||
void log_query_interface(const char* where,
|
||||
tresult result,
|
||||
const std::optional<Steinberg::FUID>& uid);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user