ICU-7286 Also fixed unnecessary String construction in various codes.

X-SVN-Rev: 27105
This commit is contained in:
Yoshito Umaoka 2009-12-18 19:54:01 +00:00
parent fd55ee2dcd
commit 02328c1edc
9 changed files with 25 additions and 30 deletions

View File

@ -4790,7 +4790,7 @@ public class Bidi {
verifyValidParaOrLine();
if (length == 0) {
/* nothing to do */
return new String("");
return "";
}
return BidiWriter.writeReordered(this, options);
@ -4844,7 +4844,7 @@ public class Bidi {
return BidiWriter.writeReverse(src, options);
} else {
/* nothing to do */
return new String("");
return "";
}
}

View File

@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (C) 2001-2007, International Business Machines
* Copyright (C) 2001-2009, International Business Machines
* Corporation and others. All Rights Reserved.
*******************************************************************************
*/
@ -42,8 +42,8 @@ final class BidiWriter {
/* optimize for several combinations of options */
switch(options&(Bidi.REMOVE_BIDI_CONTROLS|Bidi.DO_MIRRORING)) {
case 0: {
/* simply copy the LTR run to the destination */
return new String(src);
/* simply return the LTR run */
return src;
}
case Bidi.DO_MIRRORING: {
StringBuffer dest = new StringBuffer(src.length());

View File

@ -316,12 +316,8 @@ public final class CanonicalIterator {
// there were some matches, so add all the possibilities to the set.
String prefix= segment.substring(0,i);
prefix += UTF16.valueOf(cp2);
//int el = -1;
for (String item : remainder) {
String toAdd = new String(prefix);
toAdd += item;
result.add(toAdd);
//if (PROGRESS) printf("Adding: %s\n", UToS(Tr(*toAdd)));
result.add(prefix + item);
}
}
}

View File

@ -893,7 +893,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
* @stable ICU 2.0
*/
public String getLocalPatternChars() {
return new String(localPatternChars);
return localPatternChars;
}
/**

View File

@ -254,26 +254,26 @@ public class DateTimePatternGenerator implements Freezable<DateTimePatternGenera
private static void hackTimes(DateTimePatternGenerator result, PatternInfo returnInfo, String hackPattern) {
result.fp.set(hackPattern);
String mmss = new String();
StringBuilder mmss = new StringBuilder();
// to get mm:ss, we strip all but mm literal ss
boolean gotMm = false;
for (int i = 0; i < result.fp.items.size(); ++i) {
Object item = result.fp.items.get(i);
if (item instanceof String) {
if (gotMm) {
mmss += result.fp.quoteLiteral(item.toString());
mmss.append(result.fp.quoteLiteral(item.toString()));
}
} else {
char ch = item.toString().charAt(0);
if (ch == 'm') {
gotMm = true;
mmss += item;
mmss.append(item);
} else if (ch == 's') {
if (!gotMm) {
break; // failed
}
mmss += item;
result.addPattern(mmss, false, returnInfo);
mmss.append(item);
result.addPattern(mmss.toString(), false, returnInfo);
break;
} else if (gotMm || ch == 'z' || ch == 'Z' || ch == 'v' || ch == 'V') {
break; // failed
@ -303,17 +303,17 @@ public class DateTimePatternGenerator implements Freezable<DateTimePatternGenera
}
private static String getFilteredPattern(FormatParser fp, BitSet nuke) {
String result = new String();
StringBuilder result = new StringBuilder();
for (int i = 0; i < fp.items.size(); ++i) {
if (nuke.get(i)) continue;
Object item = fp.items.get(i);
if (item instanceof String) {
result += fp.quoteLiteral(item.toString());
result.append(fp.quoteLiteral(item.toString()));
} else {
result += item.toString();
result.append(item.toString());
}
}
return result;
return result.toString();
}
/*private static int getAppendNameNumber(String string) {

View File

@ -737,13 +737,12 @@ final class NFRule {
// internally we operate on a copy of the string being parsed
// (because we're going to change it) and use our own ParsePosition
ParsePosition pp = new ParsePosition(0);
String workText = new String(text);
// check to see whether the text before the first substitution
// matches the text at the beginning of the string being
// parsed. If it does, strip that off the front of workText;
// otherwise, dump out with a mismatch
workText = stripPrefix(workText, ruleText.substring(0, sub1.getPos()), pp);
String workText = stripPrefix(text, ruleText.substring(0, sub1.getPos()), pp);
int prefixLength = text.length() - workText.length();
if (pp.getIndex() == 0 && sub1.getPos() != 0) {

View File

@ -1317,7 +1317,7 @@ class FractionalPartSubstitution extends NFSubstitution {
// upperBound to 10 when calling doParse() ) until we reach
// nonmatching text
} else {
String workText = new String(text);
String workText = text;
ParsePosition workPos = new ParsePosition(1);
double result = 0;
int digit;
@ -1645,7 +1645,7 @@ class NumeratorSubstitution extends NFSubstitution {
// and use that to adjust the parse result
int zeroCount = 0;
if (withZeros) {
String workText = new String(text);
String workText = text;
ParsePosition workPos = new ParsePosition(1);
//int digit;

View File

@ -835,7 +835,7 @@ public class SimpleDateFormat extends DateFormat {
if (patternCharIndex == -1) {
throw new IllegalArgumentException("Illegal pattern character " +
"'" + ch + "' in \"" +
new String(pattern) + '"');
pattern + '"');
}
final int field = PATTERN_INDEX_TO_CALENDAR_FIELD[patternCharIndex];
@ -2918,7 +2918,7 @@ public class SimpleDateFormat extends DateFormat {
if (patternCharIndex == -1) {
throw new IllegalArgumentException("Illegal pattern character " +
"'" + ch + "' in \"" +
new String(pattern) + '"');
pattern + '"');
}
if ( patternCharIndex < highestLevel ) {
@ -3028,7 +3028,7 @@ public class SimpleDateFormat extends DateFormat {
if (patternCharIndex == -1) {
throw new IllegalArgumentException("Illegal pattern character " +
"'" + ch + "' in \"" +
new String(pattern) + '"');
pattern + '"');
}
final int field = PATTERN_INDEX_TO_CALENDAR_FIELD[patternCharIndex];
@ -3070,7 +3070,7 @@ public class SimpleDateFormat extends DateFormat {
if (patternCharIndex == -1) {
throw new IllegalArgumentException("Illegal pattern character " +
"'" + ch + "' in \"" +
new String(pattern) + '"');
pattern + '"');
}
if ( patternCharIndex >= level ) {

View File

@ -115,10 +115,10 @@ class ThaiBreakIterator extends DictionaryBasedBreakIterator {
fBeginWordSet = new UnicodeSet();
fSuffixSet = new UnicodeSet();
fThaiWordSet.applyPattern(new String("[[:Thai:]&[:LineBreak=SA:]]"));
fThaiWordSet.applyPattern("[[:Thai:]&[:LineBreak=SA:]]");
fThaiWordSet.compact();
fMarkSet.applyPattern(new String("[[:Thai:]&[:LineBreak=SA:]&[:M:]]"));
fMarkSet.applyPattern("[[:Thai:]&[:LineBreak=SA:]&[:M:]]");
fMarkSet.add(0x0020);
fEndWordSet = fThaiWordSet;
fEndWordSet.remove(0x0E31); // MAI HAN-AKAT