Skip to content

Commit

Permalink
8263321: Regression 8% in javadoc-steady in 17-b11
Browse files Browse the repository at this point in the history
Reviewed-by: prappo, vromero
  • Loading branch information
hns committed Jun 15, 2021
1 parent e36136f commit 76cad4b
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ public String toString() {
if (tsym == null || tsym.name == null) {
sb.append("<none>");
} else {
sb.append(tsym.name);
sb.append(tsym.name.toString());
}
if (moreInfo && hasTag(TYPEVAR)) {
sb.append(hashCode());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1432,7 +1432,7 @@ private boolean inAnAtag() {

@Override
public Boolean visitAttribute(AttributeTree node, Content c) {
StringBuilder sb = new StringBuilder(SPACER).append(node.getName());
StringBuilder sb = new StringBuilder(SPACER).append(node.getName().toString());
if (node.getValueKind() == ValueKind.EMPTY) {
result.add(sb);
return false;
Expand Down Expand Up @@ -2050,18 +2050,18 @@ static String getDescription(String prefix, Element elem) {
}
StringBuilder sb = new StringBuilder();
for (Element e: chain) {
CharSequence name;
String name;
switch (e.getKind()) {
case MODULE:
case PACKAGE:
name = ((QualifiedNameable) e).getQualifiedName();
name = ((QualifiedNameable) e).getQualifiedName().toString();
if (name.length() == 0) {
name = "<unnamed>";
}
break;

default:
name = e.getSimpleName();
name = e.getSimpleName().toString();
break;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ HtmlId forMember(TypeElement typeElement, VariableElement member) {
* @return the 1.4.x style anchor for the executable element
*/
protected HtmlId forErasure(ExecutableElement executableElement) {
final StringBuilder buf = new StringBuilder(executableElement.getSimpleName());
final StringBuilder buf = new StringBuilder(executableElement.getSimpleName().toString());
buf.append("(");
List<? extends VariableElement> parameters = executableElement.getParameters();
boolean foundTypeVariable = false;
Expand All @@ -237,7 +237,7 @@ public Boolean visitArray(ArrayType t, Void p) {

@Override
public Boolean visitTypeVariable(TypeVariable t, Void p) {
buf.append(utils.asTypeElement(t).getQualifiedName());
buf.append(utils.asTypeElement(t).getQualifiedName().toString());
foundTypeVariable = true;
return foundTypeVariable;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -70,17 +70,19 @@ public int charCount() {
* @return the string with all of the HTML characters escaped
*/
static String escapeHtmlChars(CharSequence s) {
for (int i = 0; i < s.length(); i++) {
char ch = s.charAt(i);
// Convert to string as CharSequence implementations can be slow - see JDK-8263321
String str = s.toString();
for (int i = 0; i < str.length(); i++) {
char ch = str.charAt(i);
switch (ch) {
// only start building a new string if we need to
case '<': case '>': case '&':
StringBuilder sb = new StringBuilder(s.subSequence(0, i));
escapeHtmlChars(s, i, sb);
StringBuilder sb = new StringBuilder(str.substring(0, i));
escapeHtmlChars(str, i, sb);
return sb.toString();
}
}
return s.toString();
return str;
}

/**
Expand All @@ -91,10 +93,10 @@ static String escapeHtmlChars(CharSequence s) {
* @param sb the string builder
*/
static void escapeHtmlChars(CharSequence s, StringBuilder sb) {
escapeHtmlChars(s, 0, sb);
escapeHtmlChars(s.toString(), 0, sb);
}

private static void escapeHtmlChars(CharSequence s, int start, StringBuilder sb) {
private static void escapeHtmlChars(String s, int start, StringBuilder sb) {
for (int i = start ; i < s.length(); i++) {
char ch = s.charAt(i);
switch (ch) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static Text of(CharSequence content) {
}

/**
* Constructor to construct FixedStringContent object.
* Constructs an immutable text object.
*
* @param content content for the object
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ private StringBuilder getText0(DocTree dt) {
new SimpleDocTreeVisitor<Void, Void>() {
@Override
public Void visitAttribute(AttributeTree node, Void p) {
sb.append(SPACER).append(node.getName());
sb.append(SPACER).append(node.getName().toString());
if (node.getValueKind() == ValueKind.EMPTY) {
return null;
}
Expand All @@ -252,7 +252,7 @@ public Void visitAttribute(AttributeTree node, Void p) {
@Override
public Void visitEndElement(EndElementTree node, Void p) {
sb.append("</")
.append(node.getName())
.append(node.getName().toString())
.append(">");
return null;
}
Expand Down Expand Up @@ -307,7 +307,7 @@ public Void visitSerial(SerialTree node, Void p) {
@Override
public Void visitStartElement(StartElementTree node, Void p) {
sb.append("<");
sb.append(node.getName());
sb.append(node.getName().toString());
node.getAttributes().forEach(dt -> dt.accept(this, null));
sb.append(node.isSelfClosing() ? "/>" : ">");
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2158,7 +2158,7 @@ public String visitModule(ModuleElement e, Void p) {

@Override
public String visitType(TypeElement e, Void p) {
StringBuilder sb = new StringBuilder(e.getSimpleName());
StringBuilder sb = new StringBuilder(e.getSimpleName().toString());
Element enclosed = e.getEnclosingElement();
while (enclosed != null
&& (enclosed.getKind().isClass() || enclosed.getKind().isInterface())) {
Expand Down

0 comments on commit 76cad4b

Please sign in to comment.