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