Skip to content

Commit e89e409

Browse files
committed
DPL: optimize for the case debugging is disabled
1 parent 4d5d8b9 commit e89e409

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

Framework/Foundation/include/Framework/Signpost.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#ifndef O2_FRAMEWORK_SIGNPOST_H_
1212
#define O2_FRAMEWORK_SIGNPOST_H_
1313

14+
#include "Framework/CompilerBuiltins.h"
1415
#include <atomic>
1516
#include <array>
1617
#ifdef __APPLE__
@@ -460,22 +461,22 @@ void _o2_log_set_stacktrace(_o2_log_t* log, int stacktrace)
460461
// they are compatible between the two implementations, we also use remove_engineering_type to remove
461462
// the engineering types from the format string, so that we can use the same format string for both.
462463
#define O2_SIGNPOST_EVENT_EMIT(log, id, name, format, ...) __extension__({ \
463-
if (O2_SIGNPOST_ENABLED_MAC(log)) { \
464+
if (O2_BUILTIN_UNLIKELY(O2_SIGNPOST_ENABLED_MAC(log))) { \
464465
O2_SIGNPOST_EVENT_EMIT_MAC(log, id, name, format, ##__VA_ARGS__); \
465-
} else if (private_o2_log_##log->stacktrace) { \
466+
} else if (O2_BUILTIN_UNLIKELY(private_o2_log_##log->stacktrace)) { \
466467
_o2_signpost_event_emit(private_o2_log_##log, id, name, remove_engineering_type(format).data(), ##__VA_ARGS__); \
467468
} \
468469
})
469470
#define O2_SIGNPOST_START(log, id, name, format, ...) \
470-
if (O2_SIGNPOST_ENABLED_MAC(log)) { \
471+
if (O2_BUILTIN_UNLIKELY(O2_SIGNPOST_ENABLED_MAC(log))) { \
471472
O2_SIGNPOST_START_MAC(log, id, name, format, ##__VA_ARGS__); \
472-
} else if (private_o2_log_##log->stacktrace) { \
473+
} else if (O2_BUILTIN_UNLIKELY(private_o2_log_##log->stacktrace)) { \
473474
_o2_signpost_interval_begin(private_o2_log_##log, id, name, remove_engineering_type(format).data(), ##__VA_ARGS__); \
474475
}
475476
#define O2_SIGNPOST_END(log, id, name, format, ...) \
476-
if (O2_SIGNPOST_ENABLED_MAC(log)) { \
477+
if (O2_BUILTIN_UNLIKELY(O2_SIGNPOST_ENABLED_MAC(log))) { \
477478
O2_SIGNPOST_END_MAC(log, id, name, format, ##__VA_ARGS__); \
478-
} else if (private_o2_log_##log->stacktrace) { \
479+
} else if (O2_BUILTIN_UNLIKELY(private_o2_log_##log->stacktrace)) { \
479480
_o2_signpost_interval_end(private_o2_log_##log, id, name, remove_engineering_type(format).data(), ##__VA_ARGS__); \
480481
}
481482
#else // This is the release implementation, it does nothing.

0 commit comments

Comments
 (0)