Skip to content

Commit

Permalink
Migrate from StringBuffer to StringBuilder
Browse files Browse the repository at this point in the history
The two APIs provide the same functionality, but `StringBuffer` performs
synchronization. `StringBuilder` should always be preferred if thread-safety is
not required.

	Change on 2017/11/07 by cushon <cushon@google.com>

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=174960662
  • Loading branch information
cushon authored and tomball committed Nov 14, 2017
1 parent c763497 commit 067cfa5
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 6 deletions.
Expand Up @@ -263,7 +263,7 @@ private String escapeCodeText(String text) {
}

// Separately test begin and end tags, to support a span with multiple Javadoc tags.
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
if (preStart > -1 && preEnd > -1) {
// Both <pre> and </pre> are in the same text segment.
sb.append(text.substring(0, preStart));
Expand Down
Expand Up @@ -20,7 +20,6 @@
import com.google.common.io.LineReader;
import com.google.devtools.j2objc.ast.TreeNode;
import com.google.devtools.j2objc.util.UnicodeUtils;

import java.io.IOException;
import java.io.StringReader;

Expand Down Expand Up @@ -214,7 +213,7 @@ public void syncFilename(String fileName) {
public String reindent(String code) {
try {
// Remove indention from each line.
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
LineReader lr = new LineReader(new StringReader(code));
String line = lr.readLine();
while (line != null) {
Expand Down
Expand Up @@ -330,7 +330,7 @@ private void printInitializeMethod() {
if (initStatements.isEmpty()) {
return;
}
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
sb.append("{\nif (self == [" + typeName + " class]) {\n");
for (Statement statement : initStatements) {
sb.append(generateStatement(statement));
Expand Down
Expand Up @@ -131,7 +131,7 @@ private void addSimpleNonArcInitialization(EnumDeclaration node) {
// retrieved from metadata, to avoid duplicates.
boolean useNamesArray = options.stripReflection() && !options.stripEnumConstants();
if (useNamesArray) {
StringBuffer sb = new StringBuffer("id names[] = {\n ");
StringBuilder sb = new StringBuilder("id names[] = {\n ");
for (EnumConstantDeclaration constant : constants) {
sb.append("@\"" + ElementUtil.getName(constant.getVariableElement()) + "\", ");
}
Expand Down
Expand Up @@ -151,7 +151,7 @@ public static boolean isValidCppCharacter(char c) {
*/
// TODO(mthvedt): Consider using this for all identifiers.
public static String asValidObjcIdentifier(String word) {
StringBuffer objcWord = new StringBuffer();
StringBuilder objcWord = new StringBuilder();
int offset = 0;

if (word.length() > 0 && Character.isDigit(word.codePointAt(0))) {
Expand Down

0 comments on commit 067cfa5

Please sign in to comment.