提交 d094ce29 编写于 作者: B bpatel

7010528: javadoc performance regression

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