3 ms·
That indeed does work great. Potentially at the expense of trashing the heap. I once wrote my own JSON parser in Java. Mostly because I couldn't abide by how h
by specialist 6y ago
That indeed does work great. Potentially at the expense of trashing the heap.
I once wrote my own JSON parser in Java. Mostly because I couldn't abide by how hard serialization was with the popular libs. I just wanted JSON to HashMap and back.
Then I got nutty trying to hyperoptimize it. Stuff like resizing methods so that JIT inlining could work.
At the time Boon was the benchmark leader. Its trick was preallocating a huge buffer per parse (and as well as taking shortcuts with the spec, accepting invalid JSON). Which I deemed wasteful. I had an HTTP server and I wanted each client connection to be lighter vs heavier. And for some reason I was committed to "stream processing" (incremental pull parser).
I could never match Boon's performance. Close. But never quite catching it. Which offended me in some way. More simple should always win, right?
Some time later I forced myself to crawl out of the rabbit hole. I backed out all my goofy optimizations. Opting for the most simple implementation I could conceive. Given my use case, my parser was more than good enough.
It's fun to tinker now and again. If only to relearn the "don't preoptimize" lesson.