9
9
*/
10
10
package org .truffleruby .core .array ;
11
11
12
- import org .truffleruby .RubyContext ;
13
12
import org .truffleruby .core .array .library .ArrayStoreLibrary ;
14
13
import org .truffleruby .core .array .library .ArrayStoreLibrary .ArrayAllocator ;
15
14
import org .truffleruby .core .array .ArrayBuilderNodeFactory .AppendArrayNodeGen ;
@@ -91,15 +90,15 @@ public Object finish(BuilderState state, int length) {
91
90
private AppendArrayNode getAppendArrayNode () {
92
91
if (appendArrayNode == null ) {
93
92
CompilerDirectives .transferToInterpreterAndInvalidate ();
94
- appendArrayNode = insert (AppendArrayNode .create (getContext () ));
93
+ appendArrayNode = insert (AppendArrayNode .create ());
95
94
}
96
95
return appendArrayNode ;
97
96
}
98
97
99
98
private AppendOneNode getAppendOneNode () {
100
99
if (appendOneNode == null ) {
101
100
CompilerDirectives .transferToInterpreterAndInvalidate ();
102
- appendOneNode = insert (AppendOneNode .create (getContext () ));
101
+ appendOneNode = insert (AppendOneNode .create ());
103
102
}
104
103
return appendOneNode ;
105
104
}
@@ -129,10 +128,10 @@ public synchronized ArrayAllocator updateStrategy(ArrayStoreLibrary.ArrayAllocat
129
128
130
129
if (newStrategy != oldStrategy ) {
131
130
if (appendArrayNode != null ) {
132
- appendArrayNode .replace (AppendArrayNode .create (getContext () ));
131
+ appendArrayNode .replace (AppendArrayNode .create ());
133
132
}
134
133
if (appendOneNode != null ) {
135
- appendOneNode .replace (AppendOneNode .create (getContext () ));
134
+ appendOneNode .replace (AppendOneNode .create ());
136
135
}
137
136
}
138
137
@@ -184,14 +183,8 @@ public BuilderState start(int length) {
184
183
@ ImportStatic (ArrayGuards .class )
185
184
public abstract static class AppendOneNode extends ArrayBuilderBaseNode {
186
185
187
- public static AppendOneNode create (RubyContext context ) {
188
- return AppendOneNodeGen .create (context );
189
- }
190
-
191
- private final RubyContext context ;
192
-
193
- public AppendOneNode (RubyContext context ) {
194
- this .context = context ;
186
+ public static AppendOneNode create () {
187
+ return AppendOneNodeGen .create ();
195
188
}
196
189
197
190
public abstract void executeAppend (BuilderState array , int index , Object value );
@@ -205,7 +198,7 @@ protected void appendCompatibleType(BuilderState state, int index, Object value,
205
198
final int length = arrays .capacity (state .store );
206
199
if (index >= length ) {
207
200
CompilerDirectives .transferToInterpreterAndInvalidate ();
208
- final int capacity = ArrayUtils .capacityForOneMore (context , length );
201
+ final int capacity = ArrayUtils .capacityForOneMore (getContext () , length );
209
202
state .store = arrays .expand (state .store , capacity );
210
203
state .capacity = capacity ;
211
204
replaceNodes (arrays .allocator (state .store ), capacity );
@@ -227,7 +220,7 @@ protected void appendNewStrategy(BuilderState state, int index, Object value,
227
220
final int currentCapacity = state .capacity ;
228
221
final int neededCapacity ;
229
222
if (index >= currentCapacity ) {
230
- neededCapacity = ArrayUtils .capacityForOneMore (context , currentCapacity );
223
+ neededCapacity = ArrayUtils .capacityForOneMore (getContext () , currentCapacity );
231
224
} else {
232
225
neededCapacity = currentCapacity ;
233
226
}
@@ -247,15 +240,10 @@ protected void appendNewStrategy(BuilderState state, int index, Object value,
247
240
@ ImportStatic (ArrayGuards .class )
248
241
public abstract static class AppendArrayNode extends ArrayBuilderBaseNode {
249
242
250
- public static AppendArrayNode create (RubyContext context ) {
251
- return AppendArrayNodeGen .create (context );
243
+ public static AppendArrayNode create () {
244
+ return AppendArrayNodeGen .create ();
252
245
}
253
246
254
- private final RubyContext context ;
255
-
256
- public AppendArrayNode (RubyContext context ) {
257
- this .context = context ;
258
- }
259
247
260
248
public abstract void executeAppend (BuilderState state , int index , RubyArray value );
261
249
@@ -273,7 +261,7 @@ protected void appendCompatibleStrategy(BuilderState state, int index, RubyArray
273
261
if (neededSize > length ) {
274
262
CompilerDirectives .transferToInterpreterAndInvalidate ();
275
263
replaceNodes (arrays .allocator (state .store ), neededSize );
276
- final int capacity = ArrayUtils .capacity (context , length , neededSize );
264
+ final int capacity = ArrayUtils .capacity (getContext () , length , neededSize );
277
265
state .store = arrays .expand (state .store , capacity );
278
266
state .capacity = capacity ;
279
267
}
@@ -300,7 +288,7 @@ protected void appendNewStrategy(BuilderState state, int index, RubyArray other,
300
288
final int currentCapacity = state .capacity ;
301
289
final int neededCapacity ;
302
290
if (neededSize > currentCapacity ) {
303
- neededCapacity = ArrayUtils .capacity (context , currentCapacity , neededSize );
291
+ neededCapacity = ArrayUtils .capacity (getContext () , currentCapacity , neededSize );
304
292
} else {
305
293
neededCapacity = currentCapacity ;
306
294
}
0 commit comments