ChangeLog: 2008-05-06 Andrew John Hughes <[EMAIL PROTECTED]>
PR classpath/21869 * java/text/AttributedString.java, * java/text/ChoiceFormat.java, * java/text/CollationElementIterator.java, * java/text/Collator.java, * java/text/DecimalFormat.java, * java/text/MessageFormat.java, * java/text/RuleBasedCollator.java: Swap use of StringBuffer for CPStringBuilder. -- Andrew :) Support Free Java! Contribute to GNU Classpath and the OpenJDK http://www.gnu.org/software/classpath http://openjdk.java.net PGP Key: 94EFD9D8 (http://subkeys.pgp.net) Fingerprint = F8EF F1EA 401E 2E60 15FA 7927 142C 2591 94EF D9D8
Index: java/text/AttributedString.java =================================================================== RCS file: /sources/classpath/classpath/java/text/AttributedString.java,v retrieving revision 1.19 diff -u -r1.19 AttributedString.java --- java/text/AttributedString.java 10 Dec 2006 20:25:46 -0000 1.19 +++ java/text/AttributedString.java 6 May 2008 22:18:37 -0000 @@ -38,6 +38,8 @@ package java.text; +import gnu.java.lang.CPStringBuilder; + import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -182,7 +184,7 @@ if ((begin < 0) || (end < begin) || end > aci.getEndIndex()) throw new IllegalArgumentException("Bad index values"); - StringBuffer sb = new StringBuffer(""); + CPStringBuilder sb = new CPStringBuilder(""); // Get the valid attribute list Set allAttribs = aci.getAllAttributeKeys(); Index: java/text/ChoiceFormat.java =================================================================== RCS file: /sources/classpath/classpath/java/text/ChoiceFormat.java,v retrieving revision 1.14 diff -u -r1.14 ChoiceFormat.java --- java/text/ChoiceFormat.java 27 Oct 2007 23:33:04 -0000 1.14 +++ java/text/ChoiceFormat.java 6 May 2008 22:18:37 -0000 @@ -39,6 +39,8 @@ package java.text; +import gnu.java.lang.CPStringBuilder; + import java.util.Vector; /** @@ -98,7 +100,7 @@ int index = 0, max = newPattern.length(); Vector stringVec = new Vector (); Vector limitVec = new Vector (); - StringBuffer buf = new StringBuffer (); + final CPStringBuilder buf = new CPStringBuilder (); while (true) { @@ -442,7 +444,7 @@ this.choiceLimits = (double[]) choiceLimits.clone(); } - private void quoteString (StringBuffer dest, String text) + private void quoteString (CPStringBuilder dest, String text) { int max = text.length(); for (int i = 0; i < max; ++i) @@ -473,7 +475,7 @@ */ public String toPattern () { - StringBuffer result = new StringBuffer (); + CPStringBuilder result = new CPStringBuilder (); for (int i = 0; i < choiceLimits.length; ++i) { result.append(choiceLimits[i]); Index: java/text/CollationElementIterator.java =================================================================== RCS file: /sources/classpath/classpath/java/text/CollationElementIterator.java,v retrieving revision 1.25 diff -u -r1.25 CollationElementIterator.java --- java/text/CollationElementIterator.java 9 Jan 2008 13:49:53 -0000 1.25 +++ java/text/CollationElementIterator.java 6 May 2008 22:18:37 -0000 @@ -38,6 +38,8 @@ package java.text; +import gnu.java.lang.CPStringBuilder; + import java.util.ArrayList; /* Written using "Java Class Libraries", 2nd edition, plus online @@ -416,7 +418,7 @@ */ public void setText(CharacterIterator source) { - StringBuffer expand = new StringBuffer(); + CPStringBuilder expand = new CPStringBuilder(); // For now assume we read from the beginning of the string. for (char c = source.first(); Index: java/text/Collator.java =================================================================== RCS file: /sources/classpath/classpath/java/text/Collator.java,v retrieving revision 1.19 diff -u -r1.19 Collator.java --- java/text/Collator.java 6 Jan 2007 01:29:08 -0000 1.19 +++ java/text/Collator.java 6 May 2008 22:18:37 -0000 @@ -406,10 +406,12 @@ // Decompose a single character and append results to the buffer. // FIXME: for libgcj this is a native method which handles // decomposition. For Classpath, for now, it does nothing. + /* final void decomposeCharacter (char c, StringBuffer buf) { buf.append (c); } + */ /** * This is the current collation decomposition setting. Index: java/text/DecimalFormat.java =================================================================== RCS file: /sources/classpath/classpath/java/text/DecimalFormat.java,v retrieving revision 1.35 diff -u -r1.35 DecimalFormat.java --- java/text/DecimalFormat.java 12 Mar 2008 23:39:50 -0000 1.35 +++ java/text/DecimalFormat.java 6 May 2008 22:18:41 -0000 @@ -43,6 +43,8 @@ package java.text; +import gnu.java.lang.CPStringBuilder; + import java.math.BigDecimal; import java.math.BigInteger; @@ -588,7 +590,7 @@ return Double.valueOf(Double.NaN); // this will be our final number - StringBuffer number = new StringBuffer(); + CPStringBuilder number = new CPStringBuilder(); // special character char minus = symbols.getMinusSign(); @@ -1003,7 +1005,7 @@ */ private String patternChars (DecimalFormatSymbols syms) { - StringBuffer buf = new StringBuffer (); + CPStringBuilder buf = new CPStringBuilder (); buf.append(syms.getDecimalSeparator()); buf.append(syms.getDigit()); @@ -1028,9 +1030,9 @@ * @param patChars * @return A StringBuffer with special characters quoted. */ - private StringBuffer quoteFix(String text, String patChars) + private CPStringBuilder quoteFix(String text, String patChars) { - StringBuffer buf = new StringBuffer(); + CPStringBuilder buf = new CPStringBuilder(); int len = text.length(); char ch; @@ -1058,7 +1060,7 @@ */ private String computePattern(DecimalFormatSymbols symbols) { - StringBuffer mainPattern = new StringBuffer(); + StringBuilder mainPattern = new StringBuilder(); // We have to at least emit a zero for the minimum number of // digits. Past that we need hash marks up to the grouping @@ -1225,7 +1227,7 @@ private int scanFix(String pattern, DecimalFormatSymbols sourceSymbols, int start, boolean prefix) { - StringBuffer buffer = new StringBuffer(); + CPStringBuilder buffer = new CPStringBuilder(); // the number portion is always delimited by one of those // characters @@ -1599,7 +1601,7 @@ DecimalFormatSymbols sourceSymbols, int start) { - StringBuffer buffer = new StringBuffer(); + StringBuilder buffer = new StringBuilder(); // the number portion is always delimited by one of those // characters @@ -2180,7 +2182,7 @@ else { char zero = symbols.getZeroDigit(); - StringBuffer _result = new StringBuffer(src); + CPStringBuilder _result = new CPStringBuilder(src); for (int i = len; i < minimumDigits; i++) { _result.append(zero); Index: java/text/MessageFormat.java =================================================================== RCS file: /sources/classpath/classpath/java/text/MessageFormat.java,v retrieving revision 1.26 diff -u -r1.26 MessageFormat.java --- java/text/MessageFormat.java 9 Jan 2008 20:42:40 -0000 1.26 +++ java/text/MessageFormat.java 6 May 2008 22:18:42 -0000 @@ -194,7 +194,7 @@ // Helper that returns the text up to the next format opener. The // text is put into BUFFER. Returns index of character after end of // string. Throws IllegalArgumentException on error. - private static int scanString(String pat, int index, StringBuffer buffer) + private static int scanString(String pat, int index, StringBuilder buffer) { int max = pat.length(); buffer.setLength(0); @@ -234,7 +234,7 @@ // This helper retrieves a single part of a format element. Returns // the index of the terminating character. private static int scanFormatElement(String pat, int index, - StringBuffer buffer, char term) + StringBuilder buffer, char term) { int max = pat.length(); buffer.setLength(0); @@ -281,7 +281,7 @@ // This is used to parse a format element and whatever non-format // text might trail it. - private static int scanFormat(String pat, int index, StringBuffer buffer, + private static int scanFormat(String pat, int index, StringBuilder buffer, Vector elts, Locale locale) { MessageFormatElement mfe = new MessageFormatElement (); @@ -342,7 +342,7 @@ { pattern = newPattern; - StringBuffer tempBuffer = new StringBuffer (); + StringBuilder tempBuffer = new StringBuilder (); int index = scanString (newPattern, 0, tempBuffer); leader = tempBuffer.toString(); Index: java/text/RuleBasedCollator.java =================================================================== RCS file: /sources/classpath/classpath/java/text/RuleBasedCollator.java,v retrieving revision 1.33 diff -u -r1.33 RuleBasedCollator.java --- java/text/RuleBasedCollator.java 9 Jan 2008 13:49:53 -0000 1.33 +++ java/text/RuleBasedCollator.java 6 May 2008 22:18:42 -0000 @@ -404,7 +404,7 @@ { boolean ignoreChars = (base_offset == 0); int operator = -1; - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); boolean doubleQuote = false; boolean eatingChars = false; boolean nextIsModifier = false;