|
@@ -151,25 +151,12 @@ public class CountersStrings {
|
|
|
public static <C extends Counter, G extends CounterGroupBase<C>,
|
|
|
T extends AbstractCounters<C, G>>
|
|
|
String toEscapedCompactString(T counters) {
|
|
|
- String[] groupsArray;
|
|
|
- int length = 0;
|
|
|
+ StringBuilder builder = new StringBuilder();
|
|
|
synchronized(counters) {
|
|
|
- groupsArray = new String[counters.countCounters()];
|
|
|
- int i = 0;
|
|
|
- // First up, obtain the escaped string for each group so that we can
|
|
|
- // determine the buffer length apriori.
|
|
|
for (G group : counters) {
|
|
|
- String escapedString = toEscapedCompactString(group);
|
|
|
- groupsArray[i++] = escapedString;
|
|
|
- length += escapedString.length();
|
|
|
+ builder.append(toEscapedCompactString(group));
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- // Now construct the buffer
|
|
|
- StringBuilder builder = new StringBuilder(length);
|
|
|
- for (String group : groupsArray) {
|
|
|
- builder.append(group);
|
|
|
- }
|
|
|
return builder.toString();
|
|
|
}
|
|
|
|