Create rapidjsondesign.md

This commit is contained in:
Daniel Lemire 2018-04-26 21:37:48 -04:00 committed by GitHub
parent bc85248978
commit 8d3c10ca74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 33 additions and 0 deletions

33
rapidjsondesign.md Normal file
View File

@ -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<parseFlags>(is);
ParseValue<parseFlags>(is, handler);
```
... which is just this...
```
void ParseValue(InputStream& is, Handler& handler) {
switch (is.Peek()) {
case 'n': ParseNull <parseFlags>(is, handler); break;
case 't': ParseTrue <parseFlags>(is, handler); break;
case 'f': ParseFalse <parseFlags>(is, handler); break;
case '"': ParseString<parseFlags>(is, handler); break;
case '{': ParseObject<parseFlags>(is, handler); break;
case '[': ParseArray <parseFlags>(is, handler); break;
default :
ParseNumber<parseFlags>(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