I've had some further progress by encoding my floating-point number into a ThreadLocal<char[]> without any garbage, but this time I miss JsonGenerator#writeNumber(char[], int, int) method. I've tried out #writeRawValue(char[], int, int), but have ended up corrupting the state. No luck so far. Any tips?
On Friday, December 27, 2019 at 12:29:19 PM UTC+1, Volkan Yazıcı wrote: > > Is there a faster way to encode floating-point numbers in JsonGenerator? > #writeNumber(double) falls back to Double.toString(), which is known to > be not very efficient <https://stackoverflow.com/q/10553710/1278899>. In > my particular case, I want to encode a j.u.Instant. Instant is, in > principle, composed of epoch seconds (integral part) and nanos (fractional > part). Hence, I can actually easily do #writeNumber("" + epochSeconds + '.' > + epochSecondsNanos). Though, this has one caveat: String allocation. Given > I have two long's denoting the integral and fractional parts of a > floating-point number, is it possible to output this via JsonGenerator > without extra allocation? > -- You received this message because you are subscribed to the Google Groups "jackson-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to jackson-user+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/jackson-user/50442704-d55b-430c-8e41-f06f6c218339%40googlegroups.com.