Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
capnproto
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
capnproto
Commits
d534ef9b
Commit
d534ef9b
authored
Jun 10, 2013
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
KJ_EXPECT_{TRUE,FALSE} -> KJ_{,UN}LIKELY
parent
40a52033
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
10 additions
and
10 deletions
+10
-10
arena.h
c++/src/capnp/arena.h
+1
-1
layout.c++
c++/src/capnp/layout.c++
+5
-5
common.h
c++/src/kj/common.h
+3
-3
debug.h
c++/src/kj/debug.h
+1
-1
No files found.
c++/src/capnp/arena.h
View file @
d534ef9b
...
...
@@ -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
{
...
...
c++/src/capnp/layout.c++
View file @
d534ef9b
...
...
@@ -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
;
}
...
...
c++/src/kj/common.h
View file @
d534ef9b
...
...
@@ -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
...
...
c++/src/kj/debug.h
View file @
d534ef9b
...
...
@@ -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())
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment