AK: Mark the error branch of the TRY() macro as unlikely

This results in a measurable (and free!) 2% improvement in test-js
run time.
This commit is contained in:
Idan Horowitz 2022-01-15 23:33:27 +02:00
parent 309d71a66b
commit 8a879e205b
Notes: sideshowbarker 2024-07-17 20:49:00 +09:00

View File

@ -9,12 +9,12 @@
// NOTE: This macro works with any result type that has the expected APIs. // NOTE: This macro works with any result type that has the expected APIs.
// It's designed with AK::Result and AK::Error in mind. // It's designed with AK::Result and AK::Error in mind.
#define TRY(expression) \ #define TRY(expression) \
({ \ ({ \
auto _temporary_result = (expression); \ auto _temporary_result = (expression); \
if (_temporary_result.is_error()) \ if (_temporary_result.is_error()) [[unlikely]] \
return _temporary_result.release_error(); \ return _temporary_result.release_error(); \
_temporary_result.release_value(); \ _temporary_result.release_value(); \
}) })
#define MUST(expression) \ #define MUST(expression) \