Commit graph

2 commits

Author SHA1 Message Date
Calin Culianu
9bf16601b9
Ensure some of the JSON tests don't end in newline
This is to test for values at end of buffer being rejected correctly.
2020-06-29 14:22:07 +03:00
Calin Culianu
26bc3520cc
Optimized JSON parsing by another ~10% or so
- JSON Number parse was needlessly pushing 1 character at a time to the
  output QByteArray.  We instead just accept characters until the end
  of token, then push the entire token as 1 call.  This avoids extra
  mallocs and extra function calls.
- Fixed a bug where the parser would accept bare "-" by itself as if it
  were a number, but then fail later.
- Optimized some expressions slightly.
- Fixed some read-past-end-of-buffer bugs (in practice would not have
  caused problems since they would technically be reading the NUL byte).
- Added more tests for corner cases (such as the '-' situation described
  above).
- Made the Json_Parser.cpp "Container" struct store the parsed
  QByteArray directly rather than it being wastefully wrapped by a
  QVariant.
- Added a note-to-self about why we didn't use a union class (it bought us
  no performance to do so and it just added boilerplate code).  Maybe in
  the future when we have std::variant on all compilers we target that
  may be a decent alternative.
2020-06-29 13:11:19 +03:00