45
45
import org .truffleruby .core .array .ArrayEachIteratorNode .ArrayElementConsumerNode ;
46
46
import org .truffleruby .core .array .ArrayIndexNodes .ReadNormalizedNode ;
47
47
import org .truffleruby .core .array .ArrayIndexNodes .ReadSliceNormalizedNode ;
48
- import org .truffleruby .core .array .ArrayNodesFactory .ReplaceNodeFactory ;
49
48
import org .truffleruby .core .array .library .ArrayStoreLibrary ;
50
49
import org .truffleruby .core .array .library .NativeArrayStorage ;
51
50
import org .truffleruby .core .array .library .SharedArrayStorage ;
64
63
import org .truffleruby .core .kernel .KernelNodes ;
65
64
import org .truffleruby .core .kernel .KernelNodes .SameOrEqlNode ;
66
65
import org .truffleruby .core .kernel .KernelNodes .SameOrEqualNode ;
67
- import org .truffleruby .core .kernel .KernelNodesFactory ;
68
66
import org .truffleruby .core .klass .RubyClass ;
69
67
import org .truffleruby .core .numeric .FixnumLowerNode ;
70
68
import org .truffleruby .core .proc .RubyProc ;
@@ -1103,7 +1101,6 @@ static boolean include(RubyArray array, Object value,
1103
1101
public abstract static class InitializeNode extends CoreMethodArrayArgumentsNode {
1104
1102
1105
1103
@ Child private DispatchNode toAryNode ;
1106
- @ Child private KernelNodes .RespondToNode respondToToAryNode ;
1107
1104
1108
1105
protected abstract RubyArray executeInitialize (RubyArray array , Object size , Object fillingValue ,
1109
1106
Object block );
@@ -1244,9 +1241,10 @@ RubyArray initializeFromArray(RubyArray array, RubyArray copy, NotProvided unuse
1244
1241
@ Specialization (
1245
1242
guards = { "!isImplicitLong(object)" , "wasProvided(object)" , "!isRubyArray(object)" })
1246
1243
RubyArray initialize (RubyArray array , Object object , NotProvided unusedValue , Nil block ,
1244
+ @ Cached KernelNodes .RespondToNode respondToNode ,
1247
1245
@ Cached @ Shared ToIntNode toIntNode ) {
1248
1246
RubyArray copy = null ;
1249
- if (respondToToAry (object )) {
1247
+ if (respondToNode . executeDoesRespondTo (object , coreSymbols (). TO_ARY , true )) {
1250
1248
Object toAryResult = callToAry (object );
1251
1249
if (toAryResult instanceof RubyArray ) {
1252
1250
copy = (RubyArray ) toAryResult ;
@@ -1261,14 +1259,6 @@ RubyArray initialize(RubyArray array, Object object, NotProvided unusedValue, Ni
1261
1259
}
1262
1260
}
1263
1261
1264
- public boolean respondToToAry (Object object ) {
1265
- if (respondToToAryNode == null ) {
1266
- CompilerDirectives .transferToInterpreterAndInvalidate ();
1267
- respondToToAryNode = insert (KernelNodesFactory .RespondToNodeFactory .create ());
1268
- }
1269
- return respondToToAryNode .executeDoesRespondTo (object , coreSymbols ().TO_ARY , true );
1270
- }
1271
-
1272
1262
protected Object callToAry (Object object ) {
1273
1263
if (toAryNode == null ) {
1274
1264
CompilerDirectives .transferToInterpreterAndInvalidate ();
@@ -1786,7 +1776,7 @@ public abstract static class ReplaceNode extends CoreMethodNode {
1786
1776
1787
1777
@ NeverDefault
1788
1778
public static ReplaceNode create () {
1789
- return ReplaceNodeFactory .create (null , null );
1779
+ return ArrayNodesFactory . ReplaceNodeFactory .create (null , null );
1790
1780
}
1791
1781
1792
1782
public abstract RubyArray executeReplace (RubyArray array , RubyArray other );
0 commit comments