In DomContent the method render(Appendable writer) is already implemented and the method render() is abstract. This should be switched for more performance.
In ContainerTag for example the method looks like this:
@Override
public void render(Appendable writer) throws IOException {
writer.append(renderOpenTag());
if (children != null && !children.isEmpty()) {
for (DomContent child : children) {
child.render(writer);
}
}
writer.append(renderCloseTag());
}
But it would be much easier to implement it like this:
@Override
public void render(Appendable writer) throws IOException {
renderOpenTag(writer);
if (children != null && !children.isEmpty()) {
for (DomContent child : children) {
child.render(writer);
}
}
renderCloseTag(writer);
}
The difference is that in the first method each child is creating and returning a String object while the second method just appends to the same Appendable object in the rendering process.
Otherwise we are just glueing Strings together instead of taking advantage of a StringBuilder.
I will send a PR later on and will add some performance tests, too. Stay tuned...
In DomContent the method
render(Appendable writer)
is already implemented and the methodrender()
is abstract. This should be switched for more performance.In ContainerTag for example the method looks like this:
But it would be much easier to implement it like this:
The difference is that in the first method each child is creating and returning a String object while the second method just appends to the same Appendable object in the rendering process.
Otherwise we are just glueing Strings together instead of taking advantage of a StringBuilder.
I will send a PR later on and will add some performance tests, too. Stay tuned...