Skip to content

Commit 116f659

Browse files
StilesCrisisStilesCrisis
authored andcommitted
Improve coverage and performance
Further improvement to perftest and hoping to make coveralls happy.
1 parent 5de7258 commit 116f659

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

include/rapidjson/reader.h

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -537,18 +537,17 @@ class GenericReader {
537537
IterativeParsingState n = Predict(state_, t);
538538
IterativeParsingState d = Transit<parseFlags>(state_, t, n, is, handler);
539539

540-
if (d == IterativeParsingErrorState) {
541-
HandleError(state_, is);
542-
return false;
543-
}
544-
545-
state_ = d;
546-
547-
// Do not further consume streams if we've parsed a complete object or hit an error.
548-
if (IsIterativeParsingCompleteState(state_)) {
549-
// If we hit an error, we are done.
550-
if (HasParseError())
540+
// If we've finished or hit an error...
541+
if (IsIterativeParsingCompleteState(d)) {
542+
// Report errors.
543+
if (d == IterativeParsingErrorState) {
544+
HandleError(state_, is);
551545
return false;
546+
}
547+
548+
// Transition to the finish state.
549+
RAPIDJSON_ASSERT(d == IterativeParsingFinishState);
550+
state_ = d;
552551

553552
// If StopWhenDone is not set...
554553
if (!(parseFlags & kParseStopWhenDoneFlag)) {
@@ -561,11 +560,14 @@ class GenericReader {
561560
}
562561
}
563562

564-
// We are done!
563+
// Success! We are done!
565564
return true;
566565
}
567566

568-
// If we found anything other than a delimiter, we invoked the handler, so we can return true now.
567+
// Transition to the new state.
568+
state_ = d;
569+
570+
// If we parsed anything other than a delimiter, we invoked the handler, so we can return true now.
569571
if (!IsIterativeParsingDelimiterState(n))
570572
return true;
571573
}

0 commit comments

Comments
 (0)