Skip to content

Commit c91b82a

Browse files
authored
Merge pull request #9 from cl4es/pr_20273_inject_cache
Cached prototype
2 parents b7e1f52 + fcc9c45 commit c91b82a

File tree

2 files changed

+196
-119
lines changed

2 files changed

+196
-119
lines changed

src/java.base/share/classes/java/lang/StringConcatHelper.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import jdk.internal.misc.Unsafe;
2929
import jdk.internal.util.DecimalDigits;
3030
import jdk.internal.vm.annotation.ForceInline;
31+
import jdk.internal.vm.annotation.Stable;
3132

3233
import java.lang.invoke.MethodHandle;
3334
import java.lang.invoke.MethodHandles;
@@ -40,6 +41,24 @@
4041
*/
4142
final class StringConcatHelper {
4243

44+
45+
static class StringConcatBase {
46+
@Stable String[] constants;
47+
@Stable int length;
48+
@Stable byte coder;
49+
StringConcatBase(String[] constants) {
50+
int length = 0;
51+
byte coder = String.LATIN1;
52+
this.constants = constants;
53+
for (String c : constants) {
54+
length += c.length();
55+
coder |= c.coder();
56+
}
57+
this.length = length;
58+
this.coder = coder;
59+
}
60+
}
61+
4362
private StringConcatHelper() {
4463
// no instantiation
4564
}

0 commit comments

Comments
 (0)