FastJSON's Hidden Costs
FastJSON's Hidden Costs
Memory Reuse
All parsed strings go into the parser object. The results always come from part of the parser’s memory.
This has downsides:
- You can’t hold onto parsed results anywhere you want
- Large JSON objects sometimes create memory fragmentation
Fast String Escaping
The code uses the standard library’s indexByte to find escape characters. If it finds none, it returns quickly. Otherwise it does the escaping work.
This has one problem: mixing escaped and unescaped strings causes performance to vary wildly.
Custom Number Parsing
FastJSON replaces strconv.ParseFloat and strconv.ParseInt with its own methods. These custom approaches optimize for speed.
The trade-off is clear: faster parsing at the cost of standard library reliability.