From 8d3c10ca74af7c1360d62151ee7be82d8bfc0a8e Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Thu, 26 Apr 2018 21:37:48 -0400 Subject: [PATCH] Create rapidjsondesign.md --- rapidjsondesign.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 rapidjsondesign.md diff --git a/rapidjsondesign.md b/rapidjsondesign.md new file mode 100644 index 00000000..3ffab785 --- /dev/null +++ b/rapidjsondesign.md @@ -0,0 +1,33 @@ +I looks like RapidJSON can process inputs at 4 cycles per byte. Rapidjson has a function that skips spaces and comments... it is obviously optimized with some SSE... + +Everything else just a series of recursive calls with switch cases. It starts like this... + +``` +SkipWhitespaceAndComments(is); +ParseValue(is, handler); +``` + +... which is just this... + +``` + void ParseValue(InputStream& is, Handler& handler) { + switch (is.Peek()) { + case 'n': ParseNull (is, handler); break; + case 't': ParseTrue (is, handler); break; + case 'f': ParseFalse (is, handler); break; + case '"': ParseString(is, handler); break; + case '{': ParseObject(is, handler); break; + case '[': ParseArray (is, handler); break; + default : + ParseNumber(is, handler); + break; + + } + } +``` + + +What RapidJSON does not do: + +- Lazy evaluation (it figures out the content of strings and numbers) +- It does not do computed gotos