Optimizing Ruby’s JSON, Part 6
After wrapping up about the encoder optimizations in the previous post, we can now start talking about the parser side.
It certainly won’t be as long, because the parser didn’t need as much work, but also because some optimizations, particularly around setup costs were the same as the one applied to the encoder, so I will simply reference them quickly.
Efficient Hash Operations
When I took over the gem, there was a pull request by Luke Gruber that had been sitting there for almost a year, with multiple parser initialization speedups.
I mentioned the first one in part two,
the parser’s #initialize
method was doing hash lookups in a very inefficient way by using rb_funcall
to check if…
#define option_given_p(opts,…