From 4394b3bac7a0647f5121a533397c0fe20c89dab8 Mon Sep 17 00:00:00 2001 From: StilesCrisis Date: Sat, 4 Feb 2017 00:05:34 -0800 Subject: [PATCH] Add LIKELY and UNLIKELY hints MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Doesn’t seem to affect timings in perftest on my machine, but it may help others. --- include/rapidjson/reader.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/rapidjson/reader.h b/include/rapidjson/reader.h index dcdc8cc..df59a1e 100644 --- a/include/rapidjson/reader.h +++ b/include/rapidjson/reader.h @@ -530,7 +530,7 @@ public: */ template bool IterativeParseNext(InputStream& is, Handler& handler) { - while (is.Peek() != '\0') { + while (RAPIDJSON_LIKELY(is.Peek() != '\0')) { SkipWhitespaceAndComments(is); Token t = Tokenize(is.Peek()); @@ -538,7 +538,7 @@ public: IterativeParsingState d = Transit(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);