I have custom deserialization logic of protocol buffers and I took advantage of field names being interned to improve performance.
https://github.com/curioswitch/protobuf-jackson/blob/main/src/main/java/org/curioswitch/common/protobuf/json/ParseSupport.java#L458
Actually, at the time I didn't know it is possible to disable interning. I was able to create a failing test for it
https://github.com/curioswitch/protobuf-jackson/blob/main/src/test/java/org/curioswitch/common/protobuf/json/JacksonInteropTest.java#L20
It would be great to be able to know if the parser is interning to be able to handle this case correctly while also skipping non-reference equality check when it's fine to do so. Currently JsonParser only exposes parser features:
https://fasterxml.github.io/jackson-core/javadoc/2.8/com/fasterxml/jackson/core/JsonParser.html#getFeatureMask()
But there is no access to the factory features. Naturally JsonParser is not the right level for that but I wonder would it be possible to expose factory features from ParserBase? Or it could just be the three standard parser implementations individually exposing it. If we could check the factory features, or more specifically whether the symbol finder is interning strings, then it would be possible to skip .equals for name comparisons.
I looked at databind, and while I'm not completely sure I understand the code, I think this optimization could be applied there too
https://github.com/FasterXML/jackson-databind/blob/2.17/src/main/java/com/fasterxml/jackson/databind/deser/impl/BeanPropertyMap.java#L575
The .equals could be skipped when it's known the fields are interned.
I have custom deserialization logic of protocol buffers and I took advantage of field names being interned to improve performance.
https://github.com/curioswitch/protobuf-jackson/blob/main/src/main/java/org/curioswitch/common/protobuf/json/ParseSupport.java#L458
Actually, at the time I didn't know it is possible to disable interning. I was able to create a failing test for it
https://github.com/curioswitch/protobuf-jackson/blob/main/src/test/java/org/curioswitch/common/protobuf/json/JacksonInteropTest.java#L20
It would be great to be able to know if the parser is interning to be able to handle this case correctly while also skipping non-reference equality check when it's fine to do so. Currently
JsonParseronly exposes parser features:https://fasterxml.github.io/jackson-core/javadoc/2.8/com/fasterxml/jackson/core/JsonParser.html#getFeatureMask()
But there is no access to the factory features. Naturally
JsonParseris not the right level for that but I wonder would it be possible to expose factory features fromParserBase? Or it could just be the three standard parser implementations individually exposing it. If we could check the factory features, or more specifically whether the symbol finder is interning strings, then it would be possible to skip.equalsfor name comparisons.I looked at databind, and while I'm not completely sure I understand the code, I think this optimization could be applied there too
https://github.com/FasterXML/jackson-databind/blob/2.17/src/main/java/com/fasterxml/jackson/databind/deser/impl/BeanPropertyMap.java#L575
The
.equalscould be skipped when it's known the fields are interned.