On Tue, Mar 28, 2023 at 3:24 PM Viktor Szathmáry <phrak...@gmail.com> wrote: > > On Mar 28, 2023, at 20:51, Tatu Saloranta <t...@fasterxml.com> wrote: > > But as I said, decoding from bytes to chars itself does not require > allocations, yet. > So `parser.getTextCharacters()` for example typically avoids > allocations (except for buffer boundaries, > long strings etc). > > > So would the following work as intended? > > public class JsonInterningDeserializer extends JsonDeserializer<String> { > > private final CharsToNameCanonicalizer can = > CharsToNameCanonicalizer.createRoot(); > > @Override > public String deserialize(JsonParser p, DeserializationContext ctxt) > throws IOException, JacksonException { > char[] buf = p.getTextCharacters(); > int start = p.getTextOffset(); > int len = p.getTextLength(); > int hash = can.calcHash(buf, start, len); > return can.findSymbol(buf, start, len, hash); > } > } > > Thanks, > Viktor
Impressive! Yes, I think that shows a simple idea that could work as intended (in this case, for `String` -valued properties. -+ Tatu +- -- 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/CAL4a10gyVsfqn93Z45jfxMSmqR1SQu1YWCA587r3SoJM1CB%3DFw%40mail.gmail.com.