Skip to content

Commit

Permalink
Add LIKELY and UNLIKELY hints
Browse files Browse the repository at this point in the history
Doesn’t seem to affect timings in perftest on my machine, but it may
help others.
  • Loading branch information
StilesCrisis authored and StilesCrisis committed Feb 4, 2017
1 parent 82a423d commit 4394b3b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions include/rapidjson/reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -530,15 +530,15 @@ class GenericReader {
*/
template <unsigned parseFlags, typename InputStream, typename Handler>
bool IterativeParseNext(InputStream& is, Handler& handler) {
while (is.Peek() != '\0') {
while (RAPIDJSON_LIKELY(is.Peek() != '\0')) {
SkipWhitespaceAndComments<parseFlags>(is);

Token t = Tokenize(is.Peek());
IterativeParsingState n = Predict(state_, t);
IterativeParsingState d = Transit<parseFlags>(state_, t, n, is, handler);

// If we've finished or hit an error...
if (IsIterativeParsingCompleteState(d)) {
if (RAPIDJSON_UNLIKELY(IsIterativeParsingCompleteState(d))) {
// Report errors.
if (d == IterativeParsingErrorState) {
HandleError(state_, is);
Expand Down

0 comments on commit 4394b3b

Please sign in to comment.