Add LIKELY and UNLIKELY hints

Doesn’t seem to affect timings in perftest on my machine, but it may
help others.
This commit is contained in:
StilesCrisis 2017-02-04 00:05:34 -08:00
parent 82a423db7d
commit 4394b3bac7

View File

@ -530,7 +530,7 @@ public:
*/
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());
@ -538,7 +538,7 @@ public:
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);