Summary: `String` and `StringBuilder` both implement `CharSequence`. Let's generalize the model for `String` to `CharSequence` wherever possible and add missing models for - `StringBuilder.append` - `StringBuilder.toString` Reviewed By: skcho Differential Revision: D19558009 fbshipit-source-id: 0dfdb21afmaster
parent
6a38121b8a
commit
d84a9e0c1c
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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);
|
||||
}
|
||||
}
|
Loading…
Reference in new issue