@@ -516,10 +516,9 @@ private void alloc(int length) {
516516
517517 private void realloc (ThreadContext context , int newLength , int valuesLength ) {
518518 unpack (context );
519- Ruby runtime = metaClass .runtime ;
520- IRubyObject [] reallocated = IRubyObject .array (validateBufferLength (runtime , newLength ));
519+ IRubyObject [] reallocated = IRubyObject .array (validateBufferLength (context .runtime , newLength ));
521520 if (newLength > valuesLength ) {
522- Helpers .fillNil (reallocated , valuesLength , newLength , runtime );
521+ Helpers .fillNil (reallocated , valuesLength , newLength , context . runtime );
523522 safeArrayCopy (context , values , begin , reallocated , 0 , valuesLength ); // elements and trailing nils
524523 } else {
525524 safeArrayCopy (context , values , begin , reallocated , 0 , newLength ); // ???
@@ -625,7 +624,7 @@ protected RubyArray<?> makeShared() {
625624 }
626625
627626 private RubyArray makeShared (ThreadContext context , int beg , int len , RubyClass klass ) {
628- return makeShared (context , beg , len , new RubyArray (klass .runtime , klass ));
627+ return makeShared (context , beg , len , new RubyArray (context .runtime , klass ));
629628 }
630629
631630 private final RubyArray makeShared (ThreadContext context , int beg , int len , RubyArray sharedArray ) {
@@ -1131,7 +1130,7 @@ private void splice(ThreadContext context, int beg, int len, final RubyArray rpl
11311130 int valuesLength = values .length - begin ;
11321131 if (beg >= realLength ) {
11331132 len = beg + rlen ;
1134- if (len >= valuesLength ) spliceRealloc (len , valuesLength );
1133+ if (len >= valuesLength ) spliceRealloc (context , len , valuesLength );
11351134 try {
11361135 Helpers .fillNil (values , begin + realLength , begin + beg , context .runtime );
11371136 } catch (ArrayIndexOutOfBoundsException e ) {
@@ -1141,7 +1140,7 @@ private void splice(ThreadContext context, int beg, int len, final RubyArray rpl
11411140 } else {
11421141 if (beg + len > realLength ) len = realLength - beg ;
11431142 int alen = realLength + rlen - len ;
1144- if (alen >= valuesLength ) spliceRealloc (alen , valuesLength );
1143+ if (alen >= valuesLength ) spliceRealloc (context , alen , valuesLength );
11451144
11461145 if (len != rlen ) {
11471146 safeArrayCopy (context , values , begin + (beg + len ), values , begin + beg + rlen , realLength - (beg + len ));
@@ -1166,13 +1165,13 @@ private final void spliceOne(ThreadContext context, long beg, IRubyObject rpl) {
11661165 int valuesLength = values .length - begin ;
11671166 if (beg >= realLength ) {
11681167 int len = (int ) beg + 1 ;
1169- if (len >= valuesLength ) spliceRealloc (len , valuesLength );
1170- Helpers .fillNil (values , begin + realLength , begin + ((int ) beg ), metaClass .runtime );
1168+ if (len >= valuesLength ) spliceRealloc (context , len , valuesLength );
1169+ Helpers .fillNil (values , begin + realLength , begin + ((int ) beg ), context .runtime );
11711170 realLength = len ;
11721171 } else {
11731172 int len = beg > realLength ? realLength - (int ) beg : 0 ;
11741173 int alen = realLength + 1 - len ;
1175- if (alen >= valuesLength ) spliceRealloc (alen , valuesLength );
1174+ if (alen >= valuesLength ) spliceRealloc (context , alen , valuesLength );
11761175
11771176 if (len == 0 ) {
11781177 safeArrayCopy (context , values , begin + (int ) beg , values , begin + (int ) beg + 1 , realLength - (int ) beg );
@@ -1183,33 +1182,29 @@ private final void spliceOne(ThreadContext context, long beg, IRubyObject rpl) {
11831182 safeArraySet (context , values , begin + (int ) beg , rpl );
11841183 }
11851184
1186- private void spliceRealloc (int length , int valuesLength ) {
1187- Ruby runtime = metaClass .runtime ;
1188-
1189- int tryLength = calculateBufferLength (runtime , valuesLength );
1185+ private void spliceRealloc (ThreadContext context , int length , int valuesLength ) {
1186+ int tryLength = calculateBufferLength (context .runtime , valuesLength );
11901187 int len = length > tryLength ? length : tryLength ;
11911188 IRubyObject [] vals = IRubyObject .array (len );
11921189 System .arraycopy (values , begin , vals , 0 , realLength );
11931190
11941191 // only fill if there actually will remain trailing storage
11951192 if (len > length ) {
1196- Helpers .fillNil (vals , length , len , runtime );
1193+ Helpers .fillNil (vals , length , len , context . runtime );
11971194 }
11981195 begin = 0 ;
11991196 values = vals ;
12001197 }
12011198
12021199 private void unshiftRealloc (ThreadContext context , int valuesLength ) {
1203- Ruby runtime = metaClass .runtime ;
1204-
12051200 int newLength = valuesLength >> 1 ;
12061201 if (newLength < ARRAY_DEFAULT_SIZE ) newLength = ARRAY_DEFAULT_SIZE ;
12071202
1208- newLength = addBufferLength (runtime , valuesLength , newLength );
1203+ newLength = addBufferLength (context . runtime , valuesLength , newLength );
12091204
12101205 IRubyObject [] vals = IRubyObject .array (newLength );
12111206 safeArrayCopy (context , values , begin , vals , 1 , valuesLength );
1212- Helpers .fillNil (vals , valuesLength + 1 , newLength , runtime );
1207+ Helpers .fillNil (vals , valuesLength + 1 , newLength , context . runtime );
12131208 values = vals ;
12141209 begin = 0 ;
12151210 }
@@ -3773,11 +3768,11 @@ private void setValuesFrom(ThreadContext context, RubyHash hash) {
37733768 }
37743769 }
37753770
3776- private void clearValues (final int from , final int to ) {
3771+ private void clearValues (ThreadContext context , final int from , final int to ) {
37773772 try {
3778- Helpers .fillNil (values , begin + from , begin + to , metaClass .runtime );
3773+ Helpers .fillNil (values , begin + from , begin + to , context .runtime );
37793774 } catch (ArrayIndexOutOfBoundsException ex ) {
3780- throw concurrentModification (getRuntime (). getCurrentContext () , ex );
3775+ throw concurrentModification (context , ex );
37813776 }
37823777 }
37833778
@@ -3793,7 +3788,7 @@ public IRubyObject uniq_bang(ThreadContext context) {
37933788 unpack (context );
37943789
37953790 setValuesFrom (context , hash );
3796- clearValues (newLength , realLength );
3791+ clearValues (context , newLength , realLength );
37973792 realLength = newLength ;
37983793
37993794 return this ;
@@ -3814,7 +3809,7 @@ public IRubyObject uniq_bang(ThreadContext context, Block block) {
38143809 unpack (context );
38153810
38163811 setValuesFrom (context , hash );
3817- clearValues (newLength , realLength );
3812+ clearValues (context , newLength , realLength );
38183813 realLength = newLength ;
38193814
38203815 return this ;
@@ -5798,7 +5793,7 @@ public boolean add(Object element) {
57985793 }
57995794
58005795 public boolean add (ThreadContext context , Object element ) {
5801- append (context , JavaUtil .convertJavaToUsableRubyObject (metaClass .runtime , element ));
5796+ append (context , JavaUtil .convertJavaToUsableRubyObject (context .runtime , element ));
58025797 return true ;
58035798 }
58045799
0 commit comments