rb_enc_str_asciionly_p: avoid always fetching the encoding
Profiling of JSON.dump shows a significant amount of time spent in rb_enc_str_asciionly_p, in large part because it fetches the encoding.
It can be made twice as fast in this scenario by first checking the coderange and only falling back to fetching the encoding if the coderange is unknown.
Additionally we can skip fetching the encoding for the common popular encodings.
rb_enc_str_asciionly_p: avoid always fetching the encoding
Profiling of
JSON.dumpshows a significant amount of time spentin
rb_enc_str_asciionly_p, in large part because it fetches theencoding.
It can be made twice as fast in this scenario by first checking the
coderange and only falling back to fetching the encoding if the
coderange is unknown.
Additionally we can skip fetching the encoding for the common
popular encodings.