You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
766 B
32 lines
766 B
5 years ago
|
/*
|
||
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
||
|
*
|
||
|
* This source code is licensed under the MIT license found in the
|
||
|
* LICENSE file in the root directory of this source tree.
|
||
|
*/
|
||
|
class StringBuilderTest {
|
||
|
|
||
|
StringBuilder mId;
|
||
|
|
||
|
void new_linear(String s) {
|
||
|
String str = new StringBuilder(s).toString();
|
||
|
for (int i = 0; i < str.length(); i++) {}
|
||
|
}
|
||
|
|
||
|
void new_constant() {
|
||
|
String s = new StringBuilder("hello").toString();
|
||
|
new_linear(s);
|
||
|
}
|
||
|
|
||
|
void new_capacity_constant() {
|
||
|
String s =
|
||
|
new StringBuilder(10).toString(); // capacity is irrelevant to underlying size of the string
|
||
|
new_linear(s);
|
||
|
}
|
||
|
|
||
|
void append_linear(String s) {
|
||
|
String str = new StringBuilder(s).append("me").toString();
|
||
|
new_linear(str);
|
||
|
}
|
||
|
}
|