Description
Currently the library internally uses AppendRaw
with safeASCII
set to true
for scenarios where it is sure that the text is correct, but for all external user types, the library forces ascii escaping.
That escape check is very expensive for large objects. E.g. for an 8MB hex string (where my type knows that it generated correct ASCII), the default encoder through MarshalText appends it to the buffer in 5.5ms, whereas setting safeASCII
to true
(hacking the lib) will cause the data to be appended to the buffer in 0.8ms. That's almost a whole order of magnitude lost time on uselessly iterating the string.
I'm not entirely sure what the solution could be, maybe a RawMessage type that does not get escaped? Or some way for a V2 marshaller to signal that the output is "final"?