XmlStringBuilder: Use potential length for target StringBuilder

This commit is contained in:
Florian Schmaus 2019-09-18 08:55:51 +02:00
parent fb3a71a14d
commit 8086a11c6c
1 changed files with 3 additions and 1 deletions

View File

@ -628,7 +628,9 @@ public class XmlStringBuilder implements Appendable, CharSequence, Element {
@Override
public CharSequence toXML(XmlEnvironment enclosingXmlEnvironment) {
StringBuilder res = new StringBuilder();
// This is only the potential length, since the actual length depends on the given XmlEnvironment.
int potentialLength = length();
StringBuilder res = new StringBuilder(potentialLength);
try {
appendXmlTo(res, enclosingXmlEnvironment);
} catch (IOException e) {