Permalink
Browse files

explain why not optimizing whitespace parsing

  • Loading branch information...
chadaustin committed Apr 18, 2017
1 parent 8eb0548 commit b05082b575aab88d6aa437b0c0dd4e7e434f34d2
Showing with 9 additions and 6 deletions.
  1. +9 −6 include/sajson.h
View
@@ -553,14 +553,17 @@ namespace sajson {
}
char* skip_whitespace(char* p) {
// There is an opportunity to make better use of superscalar
// hardware here but if someone cares about JSON parsing
// performance the first thing they do is minify, so prefer
// to optimize for code size here.
for (;;) {
if (SAJSON_LIKELY(p != input_end && !internal::is_whitespace(*p))) {
return p;
} else {
if (p == input_end) {
return 0;
}
if (SAJSON_UNLIKELY(p == input_end)) {
return 0;
} else if (internal::is_whitespace(*p)) {
++p;
} else {
return p;
}
}
}

0 comments on commit b05082b

Please sign in to comment.