Commit d534ef9b authored by Kenton Varda's avatar Kenton Varda

KJ_EXPECT_{TRUE,FALSE} -> KJ_{,UN}LIKELY

parent 40a52033
......@@ -217,7 +217,7 @@ inline ReadLimiter::ReadLimiter(WordCount64 limit): limit(limit) {}
inline void ReadLimiter::reset(WordCount64 limit) { this->limit = limit; }
inline bool ReadLimiter::canRead(WordCount amount, Arena* arena) {
if (KJ_EXPECT_FALSE(amount > limit)) {
if (KJ_UNLIKELY(amount > limit)) {
arena->reportReadLimitReached();
return false;
} else {
......
......@@ -1453,7 +1453,7 @@ struct WireHelpers {
}
const word* ptr = followFars(ref, segment);
if (KJ_EXPECT_FALSE(ptr == nullptr)) {
if (KJ_UNLIKELY(ptr == nullptr)) {
// Already reported the error.
goto useDefault;
}
......@@ -1495,7 +1495,7 @@ struct WireHelpers {
}
const word* ptr = followFars(ref, segment);
if (KJ_EXPECT_FALSE(ptr == nullptr)) {
if (KJ_UNLIKELY(ptr == nullptr)) {
// Already reported error.
goto useDefault;
}
......@@ -1627,7 +1627,7 @@ struct WireHelpers {
} else {
const word* ptr = followFars(ref, segment);
if (KJ_EXPECT_FALSE(ptr == nullptr)) {
if (KJ_UNLIKELY(ptr == nullptr)) {
// Already reported error.
goto useDefault;
}
......@@ -1674,7 +1674,7 @@ struct WireHelpers {
} else {
const word* ptr = followFars(ref, segment);
if (KJ_EXPECT_FALSE(ptr == nullptr)) {
if (KJ_UNLIKELY(ptr == nullptr)) {
// Already reported error.
goto useDefault;
}
......@@ -1723,7 +1723,7 @@ struct WireHelpers {
}
const word* ptr = WireHelpers::followFars(ref, segment);
if (KJ_EXPECT_FALSE(ptr == nullptr)) {
if (KJ_UNLIKELY(ptr == nullptr)) {
// Already reported the error.
goto useDefault;
}
......
......@@ -86,8 +86,8 @@ typedef unsigned char byte;
classname& operator=(const classname&) = delete
// Deletes the implicit copy constructor and assignment operator.
#define KJ_EXPECT_TRUE(condition) __builtin_expect(condition, true)
#define KJ_EXPECT_FALSE(condition) __builtin_expect(condition, false)
#define KJ_LIKELY(condition) __builtin_expect(condition, true)
#define KJ_UNLIKELY(condition) __builtin_expect(condition, false)
// Branch prediction macros. Evaluates to the condition given, but also tells the compiler that we
// expect the condition to be true/false enough of the time that it's worth hard-coding branch
// prediction.
......@@ -123,7 +123,7 @@ void inlineRequireFailure(
#define KJ_IREQUIRE(condition, ...)
#else
#define KJ_IREQUIRE(condition, ...) \
if (KJ_EXPECT_TRUE(condition)); else ::kj::_::inlineRequireFailure( \
if (KJ_LIKELY(condition)); else ::kj::_::inlineRequireFailure( \
__FILE__, __LINE__, #condition, #__VA_ARGS__, ##__VA_ARGS__)
// Version of KJ_REQUIRE() which is safe to use in headers that are #included by users. Used to
// check preconditions inside inline methods. KJ_INLINE_DPRECOND is particularly useful in that
......
......@@ -114,7 +114,7 @@ namespace kj {
#define KJ_DBG(...) KJ_LOG(DEBUG, ##__VA_ARGS__)
#define _kJ_FAULT(nature, cond, ...) \
if (KJ_EXPECT_TRUE(cond)) {} else \
if (KJ_LIKELY(cond)) {} else \
for (::kj::_::Debug::Fault f(__FILE__, __LINE__, ::kj::Exception::Nature::nature, 0, \
#cond, #__VA_ARGS__, ##__VA_ARGS__);; f.fatal())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment