9
9
*/
10
10
package org .truffleruby .core .rope ;
11
11
12
+ import java .util .Arrays ;
12
13
import java .util .HashMap ;
13
14
import java .util .Map ;
14
15
16
+ import com .oracle .truffle .api .CompilerDirectives .CompilationFinal ;
15
17
import org .jcodings .specific .ASCIIEncoding ;
16
18
import org .jcodings .specific .USASCIIEncoding ;
17
19
import org .jcodings .specific .UTF8Encoding ;
@@ -29,9 +31,9 @@ public class RopeConstants {
29
31
public static final LeafRope EMPTY_UTF8_ROPE = withHashCode (
30
32
new AsciiOnlyLeafRope (EMPTY_BYTES , UTF8Encoding .INSTANCE ));
31
33
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 ];
35
37
36
38
static {
37
39
for (int i = 0 ; i < 128 ; i ++) {
@@ -127,7 +129,7 @@ public static LeafRope lookupUSASCII(String string) {
127
129
}
128
130
}
129
131
130
- private static final LeafRope [] PADDED_NUMBERS = createPaddedNumbersTable ();
132
+ @ CompilationFinal ( dimensions = 1 ) private static final LeafRope [] PADDED_NUMBERS = createPaddedNumbersTable ();
131
133
132
134
private static LeafRope [] createPaddedNumbersTable () {
133
135
final LeafRope [] table = new LeafRope [100 ];
@@ -146,17 +148,15 @@ public static LeafRope paddedNumber(int n) {
146
148
return PADDED_NUMBERS [n ];
147
149
}
148
150
149
- private static final LeafRope [] PADDING_ZEROS = createPaddingZeroTable ();
151
+ @ CompilationFinal ( dimensions = 1 ) private static final LeafRope [] PADDING_ZEROS = createPaddingZeroTable ();
150
152
151
153
private static LeafRope [] createPaddingZeroTable () {
152
154
final LeafRope [] table = new LeafRope [6 ];
153
155
154
156
for (int n = 0 ; n < table .length ; n ++) {
155
157
final byte [] bytes = new byte [n ];
156
158
157
- for (int i = 0 ; i < bytes .length ; i ++) {
158
- bytes [i ] = '0' ;
159
- }
159
+ Arrays .fill (bytes , (byte ) '0' );
160
160
161
161
table [n ] = new AsciiOnlyLeafRope (bytes , UTF8Encoding .INSTANCE );
162
162
}
0 commit comments