Skip to content

Commit

Permalink
Avoid recalculating node length
Browse files Browse the repository at this point in the history
  • Loading branch information
harawata committed Nov 8, 2023
1 parent bd58d4b commit ca74a2c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main/java/org/apache/ibatis/parsing/XNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -294,11 +294,12 @@ private StringBuilder buildToString(StringBuilder builder, int indent) {
}

NodeList nodeList = node.getChildNodes();
if (nodeList == null || nodeList.getLength() == 0) {
int nodeLen = nodeList.getLength();
if (nodeList == null || nodeLen == 0) {
builder.append(" />\n");
} else {
builder.append(">\n");
for (int i = 0, n = nodeList.getLength(); i < n; i++) {
for (int i = 0, n = nodeLen; i < n; i++) {
Node node = nodeList.item(i);
short nodeType = node.getNodeType();
if (nodeType == Node.ELEMENT_NODE) {
Expand Down

0 comments on commit ca74a2c

Please sign in to comment.