Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8274525: Replace uses of StringBuffer with StringBuilder in java.xml #5759

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -461,13 +461,10 @@ public final boolean isUnparsed() {

/** Returns a string representation of this object. */
public String toString() {

StringBuffer str = new StringBuffer();
str.append("name=\""+name+'"');
str.append(",ch="+ new String(ch));
str.append(",position="+position);
str.append(",count="+count);
return str.toString();
return "name=\"" + name + '"' +
",ch=" + new String(ch) +
",position=" + position +
",count=" + count;

} // toString():String

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 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
@@ -93,7 +93,7 @@ public String reportError(XMLLocator location,
message = messageFormatter.formatMessage(fLocale, key, arguments);
}
else {
StringBuffer str = new StringBuffer();
StringBuilder str = new StringBuilder();
str.append(domain);
str.append('#');
str.append(key);
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 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
@@ -142,8 +142,8 @@ else if(type == XMLEvent.COMMENT || type == XMLEvent.PROCESSING_INSTRUCTION){
return "";
}

//create the string buffer and add initial data
StringBuffer buffer = new StringBuffer();
//create the string builder and add initial data
StringBuilder buffer = new StringBuilder();
if(data != null && data.length() > 0 ) {
buffer.append(data);
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 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
@@ -67,18 +67,11 @@ public String getSystemId(){
}

public String toString(){
StringBuffer sbuffer = new StringBuffer() ;
sbuffer.append("Line number = " + getLineNumber());
sbuffer.append("\n") ;
sbuffer.append("Column number = " + getColumnNumber());
sbuffer.append("\n") ;
sbuffer.append("System Id = " + getSystemId());
sbuffer.append("\n") ;
sbuffer.append("Public Id = " + getPublicId());
sbuffer.append("\n") ;
sbuffer.append("CharacterOffset = " + getCharacterOffset());
sbuffer.append("\n") ;
return sbuffer.toString();
return "Line number = " + getLineNumber() + "\n" +
"Column number = " + getColumnNumber() + "\n" +
"System Id = " + getSystemId() + "\n" +
"Public Id = " + getPublicId() + "\n" +
"CharacterOffset = " + getCharacterOffset() + "\n";
}

}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 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
@@ -885,8 +885,7 @@ public boolean equals(final Object duration) {
* @return A non-{@code null} valid {@code String} representation of this {@code Duration}.
*/
public String toString() {

StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();

if (getSign() < 0) {
buf.append('-');
@@ -946,15 +945,15 @@ private String toString(BigDecimal bd) {
}

/* Insert decimal point */
StringBuffer buf;
StringBuilder buf;
int insertionPoint = intString.length() - scale;
if (insertionPoint == 0) { /* Point goes right before intVal */
return "0." + intString;
} else if (insertionPoint > 0) { /* Point goes inside intVal */
buf = new StringBuffer(intString);
buf = new StringBuilder(intString);
buf.insert(insertionPoint, '.');
} else { /* We must insert zeros between point and intVal */
buf = new StringBuffer(3 - insertionPoint + intString.length());
buf = new StringBuilder(3 - insertionPoint + intString.length());
buf.append("0.");
for (int i = 0; i < -insertionPoint; i++) {
buf.append('0');