Do not recreate nodes if merge does nothing

This commit is contained in:
Guillaume Nodet 2024-04-02 15:05:57 +02:00
parent a6f52774eb
commit 97518b5b29
1 changed files with 9 additions and 2 deletions

View File

@ -357,8 +357,15 @@ public static XmlNode merge(XmlNode dominant, XmlNode recessive, Boolean childMe
if (children == null) {
children = dominant.getChildren();
}
return new XmlNodeImpl(
dominant.getName(), value != null ? value : dominant.getValue(), attrs, children, location);
if (!Objects.equals(value, dominant.getValue())
|| !Objects.equals(attrs, dominant.getAttributes())
|| !Objects.equals(children, dominant.getChildren())
|| !Objects.equals(location, dominant.getInputLocation())) {
return new XmlNodeImpl(
dominant.getName(), value != null ? value : dominant.getValue(), attrs, children, location);
} else {
return dominant;
}
}
}
return dominant;