Skip to content

Commit 43eff2b

Browse files
justin-curtis-luBrent Christian
authored and
Brent Christian
committedSep 26, 2022
8272687: Replace StringBuffer with StringBuilder in RuleBasedCollator
Reviewed-by: lancea, naoto, bchristi, bpb
1 parent b88ee1e commit 43eff2b

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed
 

‎src/java.base/share/classes/java/text/RBCollationTables.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ short getMaxTerOrder() {
243243
*/
244244
//shemran/Note: this is used for secondary order value reverse, no
245245
// need to consider supplementary pair.
246-
static void reverse (StringBuffer result, int from, int to)
246+
static void reverse (StringBuilder result, int from, int to)
247247
{
248248
int i = from;
249249
char swap;

‎src/java.base/share/classes/java/text/RuleBasedCollator.java

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -605,9 +605,9 @@ public synchronized CollationKey getCollationKey(String source)
605605
return null;
606606

607607
if (primResult == null) {
608-
primResult = new StringBuffer();
609-
secResult = new StringBuffer();
610-
terResult = new StringBuffer();
608+
primResult = new StringBuilder();
609+
secResult = new StringBuilder();
610+
terResult = new StringBuilder();
611611
} else {
612612
primResult.setLength(0);
613613
secResult.setLength(0);
@@ -681,8 +681,8 @@ public synchronized CollationKey getCollationKey(String source)
681681
}
682682
primResult.append((char)0);
683683
secResult.append((char)0);
684-
secResult.append(terResult.toString());
685-
primResult.append(secResult.toString());
684+
secResult.append(terResult);
685+
primResult.append(secResult);
686686

687687
if (getStrength() == IDENTICAL) {
688688
primResult.append((char)0);
@@ -762,9 +762,9 @@ RBCollationTables getTables() {
762762

763763
// Internal objects that are cached across calls so that they don't have to
764764
// be created/destroyed on every call to compare() and getCollationKey()
765-
private StringBuffer primResult = null;
766-
private StringBuffer secResult = null;
767-
private StringBuffer terResult = null;
765+
private StringBuilder primResult = null;
766+
private StringBuilder secResult = null;
767+
private StringBuilder terResult = null;
768768
private CollationElementIterator sourceCursor = null;
769769
private CollationElementIterator targetCursor = null;
770770
}

0 commit comments

Comments
 (0)
Please sign in to comment.