Use C++20 [[unlikely]] instead of BOOST_UNLIKELY

This commit is contained in:
Robbert van der Helm
2021-05-31 17:46:45 +02:00
parent 6a047497bc
commit 2bf1c4c5eb
5 changed files with 10 additions and 10 deletions
+1 -1
View File
@@ -208,7 +208,7 @@ inline T& read_object(Socket& socket,
bitsery::quickDeserialization<InputAdapter<SerializationBufferBase>>( bitsery::quickDeserialization<InputAdapter<SerializationBufferBase>>(
{buffer.begin(), size}, object); {buffer.begin(), size}, object);
if (BOOST_UNLIKELY(!success)) { if (!success) [[unlikely]] {
throw std::runtime_error("Deserialization failure in call: " + throw std::runtime_error("Deserialization failure in call: " +
std::string(__PRETTY_FUNCTION__)); std::string(__PRETTY_FUNCTION__));
} }
+6 -6
View File
@@ -327,7 +327,7 @@ std::optional<std::string> opcode_to_string(bool is_dispatch, int opcode) {
} }
void Vst2Logger::log_get_parameter(int index) { void Vst2Logger::log_get_parameter(int index) {
if (BOOST_UNLIKELY(logger.verbosity >= Logger::Verbosity::most_events)) { if (logger.verbosity >= Logger::Verbosity::most_events) [[unlikely]] {
std::ostringstream message; std::ostringstream message;
message << ">> getParameter() " << index; message << ">> getParameter() " << index;
@@ -336,7 +336,7 @@ void Vst2Logger::log_get_parameter(int index) {
} }
void Vst2Logger::log_get_parameter_response(float value) { void Vst2Logger::log_get_parameter_response(float value) {
if (BOOST_UNLIKELY(logger.verbosity >= Logger::Verbosity::most_events)) { if (logger.verbosity >= Logger::Verbosity::most_events) [[unlikely]] {
std::ostringstream message; std::ostringstream message;
message << " getParameter() :: " << value; message << " getParameter() :: " << value;
@@ -345,7 +345,7 @@ void Vst2Logger::log_get_parameter_response(float value) {
} }
void Vst2Logger::log_set_parameter(int index, float value) { void Vst2Logger::log_set_parameter(int index, float value) {
if (BOOST_UNLIKELY(logger.verbosity >= Logger::Verbosity::most_events)) { if (logger.verbosity >= Logger::Verbosity::most_events) [[unlikely]] {
std::ostringstream message; std::ostringstream message;
message << ">> setParameter() " << index << " = " << value; message << ">> setParameter() " << index << " = " << value;
@@ -354,7 +354,7 @@ void Vst2Logger::log_set_parameter(int index, float value) {
} }
void Vst2Logger::log_set_parameter_response() { void Vst2Logger::log_set_parameter_response() {
if (BOOST_UNLIKELY(logger.verbosity >= Logger::Verbosity::most_events)) { if (logger.verbosity >= Logger::Verbosity::most_events) [[unlikely]] {
log(" setParameter() :: OK"); log(" setParameter() :: OK");
} }
} }
@@ -367,7 +367,7 @@ void Vst2Logger::log_event(
const Vst2Event::Payload& payload, const Vst2Event::Payload& payload,
float option, float option,
const std::optional<Vst2Event::Payload>& value_payload) { const std::optional<Vst2Event::Payload>& value_payload) {
if (BOOST_UNLIKELY(logger.verbosity >= Logger::Verbosity::most_events)) { if (logger.verbosity >= Logger::Verbosity::most_events) [[unlikely]] {
if (should_filter_event(is_dispatch, opcode)) { if (should_filter_event(is_dispatch, opcode)) {
return; return;
} }
@@ -455,7 +455,7 @@ void Vst2Logger::log_event_response(
const Vst2EventResult::Payload& payload, const Vst2EventResult::Payload& payload,
const std::optional<Vst2EventResult::Payload>& value_payload, const std::optional<Vst2EventResult::Payload>& value_payload,
bool from_cache) { bool from_cache) {
if (BOOST_UNLIKELY(logger.verbosity >= Logger::Verbosity::most_events)) { if (logger.verbosity >= Logger::Verbosity::most_events) [[unlikely]] {
if (should_filter_event(is_dispatch, opcode)) { if (should_filter_event(is_dispatch, opcode)) {
return; return;
} }
+1 -1
View File
@@ -57,7 +57,7 @@ void Vst3Logger::log_query_interface(
const std::string& where, const std::string& where,
tresult result, tresult result,
const std::optional<Steinberg::FUID>& uid) { const std::optional<Steinberg::FUID>& uid) {
if (BOOST_UNLIKELY(logger.verbosity >= Logger::Verbosity::all_events)) { if (logger.verbosity >= Logger::Verbosity::all_events) [[unlikely]] {
std::ostringstream message; std::ostringstream message;
std::string uid_string = uid ? format_uid(*uid) : "<unknown_pointer>"; std::string uid_string = uid ? format_uid(*uid) : "<unknown_pointer>";
+1 -1
View File
@@ -355,7 +355,7 @@ class Vst3Logger {
bool log_request_base(bool is_host_vst, bool log_request_base(bool is_host_vst,
Logger::Verbosity min_verbosity, Logger::Verbosity min_verbosity,
F callback) { F callback) {
if (BOOST_UNLIKELY(logger.verbosity >= min_verbosity)) { if (logger.verbosity >= min_verbosity) [[unlikely]] {
std::ostringstream message; std::ostringstream message;
if (is_host_vst) { if (is_host_vst) {
message << "[host -> vst] >> "; message << "[host -> vst] >> ";
+1 -1
View File
@@ -462,7 +462,7 @@ intptr_t Vst2PluginBridge::dispatch(AEffect* /*plugin*/,
// been a release that contains the fix yet. This should be removed // been a release that contains the fix yet. This should be removed
// once Ardour 6.0 gets released. // once Ardour 6.0 gets released.
// https://tracker.ardour.org/view.php?id=7668 // https://tracker.ardour.org/view.php?id=7668
if (BOOST_UNLIKELY(plugin.magic == 0)) { if (plugin.magic == 0) [[unlikely]] {
logger.log_event(true, opcode, index, value, nullptr, option, logger.log_event(true, opcode, index, value, nullptr, option,
std::nullopt); std::nullopt);
logger.log( logger.log(