[CDRIVER-2525] JSON parser cleanups Created: 02/Mar/18 Updated: 27/Oct/23 Resolved: 12/Apr/18 |
|
| Status: | Closed |
| Project: | C Driver |
| Component/s: | json |
| Affects Version/s: | None |
| Fix Version/s: | 1.10.0 |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | A. Jesse Jiryu Davis | Assignee: | A. Jesse Jiryu Davis |
| Resolution: | Works as Designed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
The first frame of the JSON parser stack is never used; it's substituted with a separate bson_t in bson_json_reader_bson_t.bson. Much of the code would be simpler if we use bson_json_reader_bson_t.stack[0].bson as the root object instead. Additionally, there are many checks for "bson_json_reader_bson_t.n > 0" which I believe are always true as the parser descends into the JSON object. |
| Comments |
| Comment by A. Jesse Jiryu Davis [ 12/Apr/18 ] | |||
|
Nevermind, I realize that the document at the root of the parser stack may belong to the caller:
This allows us to construct a BSON document in-place as we parse the JSON stream. For a stream containing large numbers of small documents this could be a significant win, which is why the parser is designed with this quirk. |