Skip to content

Commit

Permalink
8272687: Replace StringBuffer with StringBuilder in RuleBasedCollator
Browse files Browse the repository at this point in the history
Reviewed-by: lancea, naoto, bchristi, bpb
  • Loading branch information
justin-curtis-lu authored and Brent Christian committed Sep 26, 2022
1 parent b88ee1e commit 43eff2b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ short getMaxTerOrder() {
*/
//shemran/Note: this is used for secondary order value reverse, no
// need to consider supplementary pair.
static void reverse (StringBuffer result, int from, int to)
static void reverse (StringBuilder result, int from, int to)
{
int i = from;
char swap;
Expand Down
18 changes: 9 additions & 9 deletions src/java.base/share/classes/java/text/RuleBasedCollator.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -605,9 +605,9 @@ public synchronized CollationKey getCollationKey(String source)
return null;

if (primResult == null) {
primResult = new StringBuffer();
secResult = new StringBuffer();
terResult = new StringBuffer();
primResult = new StringBuilder();
secResult = new StringBuilder();
terResult = new StringBuilder();
} else {
primResult.setLength(0);
secResult.setLength(0);
Expand Down Expand Up @@ -681,8 +681,8 @@ public synchronized CollationKey getCollationKey(String source)
}
primResult.append((char)0);
secResult.append((char)0);
secResult.append(terResult.toString());
primResult.append(secResult.toString());
secResult.append(terResult);
primResult.append(secResult);

if (getStrength() == IDENTICAL) {
primResult.append((char)0);
Expand Down Expand Up @@ -762,9 +762,9 @@ RBCollationTables getTables() {

// Internal objects that are cached across calls so that they don't have to
// be created/destroyed on every call to compare() and getCollationKey()
private StringBuffer primResult = null;
private StringBuffer secResult = null;
private StringBuffer terResult = null;
private StringBuilder primResult = null;
private StringBuilder secResult = null;
private StringBuilder terResult = null;
private CollationElementIterator sourceCursor = null;
private CollationElementIterator targetCursor = null;
}

1 comment on commit 43eff2b

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.