Skip to content

Commit 188e25d

Browse files
committed
CODEC-143 StringBuffer could be replaced by StringBuilder for local variables
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/codec/trunk@1333721 13f79535-47bb-0310-9956-ffa450edef68
1 parent 3077398 commit 188e25d

6 files changed

Lines changed: 14 additions & 11 deletions

File tree

src/changes/changes.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ The <action> type attribute can be add,update,fix,remove.
5151
</release>
5252
-->
5353
<release version="1.7" date="TBD" description="Feature and fix release.">
54+
<action issue="CODEC-143" dev="sebb" type="update">
55+
StringBuffer could be replaced by StringBuilder for local variables.
56+
</action>
5457
<action dev="ggregory" type="add" issue="CODEC-139" due-to="dsebastien">
5558
DigestUtils: add updateDigest methods and make methods public.
5659
</action>

src/main/java/org/apache/commons/codec/language/DoubleMetaphone.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,8 +1035,8 @@ protected static boolean contains(String value, int start, int length,
10351035
*/
10361036
public class DoubleMetaphoneResult {
10371037

1038-
private final StringBuffer primary = new StringBuffer(getMaxCodeLen());
1039-
private final StringBuffer alternate = new StringBuffer(getMaxCodeLen());
1038+
private final StringBuilder primary = new StringBuilder(getMaxCodeLen());
1039+
private final StringBuilder alternate = new StringBuilder(getMaxCodeLen());
10401040
private final int maxLength;
10411041

10421042
public DoubleMetaphoneResult(int maxLength) {

src/main/java/org/apache/commons/codec/language/Metaphone.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ public String metaphone(String txt) {
9797

9898
char[] inwd = txt.toUpperCase(java.util.Locale.ENGLISH).toCharArray() ;
9999

100-
StringBuffer local = new StringBuffer(40); // manipulate
101-
StringBuffer code = new StringBuffer(10) ; // output
100+
StringBuilder local = new StringBuilder(40); // manipulate
101+
StringBuilder code = new StringBuilder(10) ; // output
102102
// handle initial 2 characters exceptions
103103
switch(inwd[0]) {
104104
case 'K' :
@@ -320,11 +320,11 @@ public String metaphone(String txt) {
320320
return code.toString();
321321
}
322322

323-
private boolean isVowel(StringBuffer string, int index) {
323+
private boolean isVowel(StringBuilder string, int index) {
324324
return VOWELS.indexOf(string.charAt(index)) >= 0;
325325
}
326326

327-
private boolean isPreviousChar(StringBuffer string, int index, char c) {
327+
private boolean isPreviousChar(StringBuilder string, int index, char c) {
328328
boolean matches = false;
329329
if( index > 0 &&
330330
index < string.length() ) {
@@ -333,7 +333,7 @@ private boolean isPreviousChar(StringBuffer string, int index, char c) {
333333
return matches;
334334
}
335335

336-
private boolean isNextChar(StringBuffer string, int index, char c) {
336+
private boolean isNextChar(StringBuilder string, int index, char c) {
337337
boolean matches = false;
338338
if( index >= 0 &&
339339
index < string.length() - 1 ) {
@@ -342,7 +342,7 @@ private boolean isNextChar(StringBuffer string, int index, char c) {
342342
return matches;
343343
}
344344

345-
private boolean regionMatch(StringBuffer string, int index, String test) {
345+
private boolean regionMatch(StringBuilder string, int index, String test) {
346346
boolean matches = false;
347347
if( index >= 0 &&
348348
index + test.length() - 1 < string.length() ) {

src/main/java/org/apache/commons/codec/language/Nysiis.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ public String nysiis(String str) {
272272
str = PAT_DT_ETC.matcher(str).replaceFirst("D");
273273

274274
// First character of key = first character of name.
275-
StringBuffer key = new StringBuffer(str.length());
275+
StringBuilder key = new StringBuilder(str.length());
276276
key.append(str.charAt(0));
277277

278278
// Transcode remaining characters, incrementing by one character each time

src/main/java/org/apache/commons/codec/language/RefinedSoundex.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ public String soundex(String str) {
181181
return str;
182182
}
183183

184-
StringBuffer sBuf = new StringBuffer();
184+
StringBuilder sBuf = new StringBuilder();
185185
sBuf.append(str.charAt(0));
186186

187187
char last, current;

src/main/java/org/apache/commons/codec/net/RFC1522Codec.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ protected String encodeText(final String text, final Charset charset)
8484
if (text == null) {
8585
return null;
8686
}
87-
StringBuffer buffer = new StringBuffer();
87+
StringBuilder buffer = new StringBuilder();
8888
buffer.append(PREFIX);
8989
buffer.append(charset);
9090
buffer.append(SEP);

0 commit comments

Comments
 (0)