Skip to content

Commit 670df7c

Browse files
committed
[GR-17457] Mark RopeConstants arrays as CompilationFinal
PullRequest: truffleruby/2686
2 parents 42a4b60 + 3ced42d commit 670df7c

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/main/java/org/truffleruby/core/rope/RopeConstants.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99
*/
1010
package org.truffleruby.core.rope;
1111

12+
import java.util.Arrays;
1213
import java.util.HashMap;
1314
import java.util.Map;
1415

16+
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
1517
import org.jcodings.specific.ASCIIEncoding;
1618
import org.jcodings.specific.USASCIIEncoding;
1719
import org.jcodings.specific.UTF8Encoding;
@@ -29,9 +31,9 @@ public class RopeConstants {
2931
public static final LeafRope EMPTY_UTF8_ROPE = withHashCode(
3032
new AsciiOnlyLeafRope(EMPTY_BYTES, UTF8Encoding.INSTANCE));
3133

32-
public static final LeafRope[] UTF8_SINGLE_BYTE_ROPES = new LeafRope[256];
33-
public static final LeafRope[] US_ASCII_SINGLE_BYTE_ROPES = new LeafRope[256];
34-
public static final LeafRope[] ASCII_8BIT_SINGLE_BYTE_ROPES = new LeafRope[256];
34+
@CompilationFinal(dimensions = 1) public static final LeafRope[] UTF8_SINGLE_BYTE_ROPES = new LeafRope[256];
35+
@CompilationFinal(dimensions = 1) public static final LeafRope[] US_ASCII_SINGLE_BYTE_ROPES = new LeafRope[256];
36+
@CompilationFinal(dimensions = 1) public static final LeafRope[] ASCII_8BIT_SINGLE_BYTE_ROPES = new LeafRope[256];
3537

3638
static {
3739
for (int i = 0; i < 128; i++) {
@@ -127,7 +129,7 @@ public static LeafRope lookupUSASCII(String string) {
127129
}
128130
}
129131

130-
private static final LeafRope[] PADDED_NUMBERS = createPaddedNumbersTable();
132+
@CompilationFinal(dimensions = 1) private static final LeafRope[] PADDED_NUMBERS = createPaddedNumbersTable();
131133

132134
private static LeafRope[] createPaddedNumbersTable() {
133135
final LeafRope[] table = new LeafRope[100];
@@ -146,17 +148,15 @@ public static LeafRope paddedNumber(int n) {
146148
return PADDED_NUMBERS[n];
147149
}
148150

149-
private static final LeafRope[] PADDING_ZEROS = createPaddingZeroTable();
151+
@CompilationFinal(dimensions = 1) private static final LeafRope[] PADDING_ZEROS = createPaddingZeroTable();
150152

151153
private static LeafRope[] createPaddingZeroTable() {
152154
final LeafRope[] table = new LeafRope[6];
153155

154156
for (int n = 0; n < table.length; n++) {
155157
final byte[] bytes = new byte[n];
156158

157-
for (int i = 0; i < bytes.length; i++) {
158-
bytes[i] = '0';
159-
}
159+
Arrays.fill(bytes, (byte) '0');
160160

161161
table[n] = new AsciiOnlyLeafRope(bytes, UTF8Encoding.INSTANCE);
162162
}

0 commit comments

Comments
 (0)