提交 d094ce29 编写于 作者: B bpatel

7010528: javadoc performance regression

Reviewed-by: jjg
上级 80ba8459
...@@ -755,22 +755,30 @@ public class HtmlTree extends Content { ...@@ -755,22 +755,30 @@ public class HtmlTree extends Content {
if (!isInline() && !endsWithNewLine(contentBuilder)) if (!isInline() && !endsWithNewLine(contentBuilder))
contentBuilder.append(DocletConstants.NL); contentBuilder.append(DocletConstants.NL);
String tagString = htmlTag.toString(); String tagString = htmlTag.toString();
contentBuilder.append("<" + tagString); contentBuilder.append("<");
contentBuilder.append(tagString);
Iterator<HtmlAttr> iterator = attrs.keySet().iterator(); Iterator<HtmlAttr> iterator = attrs.keySet().iterator();
HtmlAttr key; HtmlAttr key;
String value = ""; String value = "";
while (iterator.hasNext()) { while (iterator.hasNext()) {
key = iterator.next(); key = iterator.next();
value = attrs.get(key); value = attrs.get(key);
contentBuilder.append(" " + key.toString()); contentBuilder.append(" ");
if (!value.isEmpty()) contentBuilder.append(key.toString());
contentBuilder.append("=\"" + value + "\""); if (!value.isEmpty()) {
contentBuilder.append("=\"");
contentBuilder.append(value);
contentBuilder.append("\"");
}
} }
contentBuilder.append(">"); contentBuilder.append(">");
for (Content c : content) for (Content c : content)
c.write(contentBuilder); c.write(contentBuilder);
if (htmlTag.endTagRequired()) if (htmlTag.endTagRequired()) {
contentBuilder.append("</" + tagString + ">"); contentBuilder.append("</");
contentBuilder.append(tagString);
contentBuilder.append(">");
}
if (!isInline()) if (!isInline())
contentBuilder.append(DocletConstants.NL); contentBuilder.append(DocletConstants.NL);
} }
......
...@@ -99,8 +99,24 @@ public abstract class Content { ...@@ -99,8 +99,24 @@ public abstract class Content {
* @param contentBuilder content to test for newline character at the end * @param contentBuilder content to test for newline character at the end
* @return true if the content ends with newline. * @return true if the content ends with newline.
*/ */
public boolean endsWithNewLine(StringBuilder contentBuilder) { protected boolean endsWithNewLine(StringBuilder contentBuilder) {
return ((contentBuilder.length() == 0) || int contentLength = contentBuilder.length();
(contentBuilder.toString().endsWith(DocletConstants.NL))); if (contentLength == 0) {
return true;
}
int nlLength = DocletConstants.NL.length();
if (contentLength < nlLength) {
return false;
}
int contentIndex = contentLength - 1;
int nlIndex = nlLength - 1;
while (nlIndex >= 0) {
if (contentBuilder.charAt(contentIndex) != DocletConstants.NL.charAt(nlIndex)) {
return false;
}
contentIndex--;
nlIndex--;
}
return true;
} }
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册