Skip to content

Commit 318ab68

Browse files
committed
Minor optimization post #3965 for custom ObjectNodes
1 parent 809d7f1 commit 318ab68

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/main/java/com/fasterxml/jackson/databind/node/ObjectNode.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,9 @@ protected void serializeFilteredContents(final JsonGenerator g, final Serializer
546546
*/
547547
protected Map<String, JsonNode> _contentsToSerialize(SerializerProvider ctxt) {
548548
if (ctxt.isEnabled(JsonNodeFeature.WRITE_PROPERTIES_SORTED)) {
549-
if (!_children.isEmpty()) {
549+
if (!_children.isEmpty()
550+
// 02-Jun-2024, tatu: Avoid unnecessary copy for custom impls
551+
&& !(_children instanceof TreeMap<?,?>)) {
550552
return new TreeMap<>(_children);
551553
}
552554
}

0 commit comments

Comments
 (0)