Skip to content

Commit 4394b3b

Browse files
StilesCrisisStilesCrisis
authored andcommitted
Add LIKELY and UNLIKELY hints
Doesn’t seem to affect timings in perftest on my machine, but it may help others.
1 parent 82a423d commit 4394b3b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

include/rapidjson/reader.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,15 +530,15 @@ class GenericReader {
530530
*/
531531
template <unsigned parseFlags, typename InputStream, typename Handler>
532532
bool IterativeParseNext(InputStream& is, Handler& handler) {
533-
while (is.Peek() != '\0') {
533+
while (RAPIDJSON_LIKELY(is.Peek() != '\0')) {
534534
SkipWhitespaceAndComments<parseFlags>(is);
535535

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

540540
// If we've finished or hit an error...
541-
if (IsIterativeParsingCompleteState(d)) {
541+
if (RAPIDJSON_UNLIKELY(IsIterativeParsingCompleteState(d))) {
542542
// Report errors.
543543
if (d == IterativeParsingErrorState) {
544544
HandleError(state_, is);

0 commit comments

Comments
 (0)