@@ -129,17 +129,7 @@ private static void resize(RubyHash hash) {
129
129
130
130
while (entry != null ) {
131
131
final int bucketIndex = getBucketIndex (entry .getHashed (), bucketsCount );
132
- Entry previousInLookup = newEntries [bucketIndex ];
133
-
134
- if (previousInLookup == null ) {
135
- newEntries [bucketIndex ] = entry ;
136
- } else {
137
- while (previousInLookup .getNextInLookup () != null ) {
138
- previousInLookup = previousInLookup .getNextInLookup ();
139
- }
140
-
141
- previousInLookup .setNextInLookup (entry );
142
- }
132
+ appendToLookupChain (newEntries , entry , bucketIndex );
143
133
144
134
entry .setNextInLookup (null );
145
135
entry = entry .getNextInSequence ();
@@ -186,6 +176,25 @@ private static void removeFromLookupChain(Entry[] entries, int index, Entry entr
186
176
}
187
177
}
188
178
179
+ static void appendToLookupChain (Entry [] entries , Entry entry , int bucketIndex ) {
180
+ Entry previousInLookup = entries [bucketIndex ];
181
+
182
+ if (previousInLookup == null ) {
183
+ entries [bucketIndex ] = entry ;
184
+ } else {
185
+ while (true ) {
186
+ final Entry nextInLookup = previousInLookup .getNextInLookup ();
187
+ if (nextInLookup == null ) {
188
+ break ;
189
+ } else {
190
+ previousInLookup = nextInLookup ;
191
+ }
192
+ }
193
+
194
+ previousInLookup .setNextInLookup (entry );
195
+ }
196
+ }
197
+
189
198
// endregion
190
199
// region Messages
191
200
@@ -420,11 +429,7 @@ protected RubyArray shift(RubyHash hash,
420
429
Entry entry = entries [index ];
421
430
while (entry != null ) {
422
431
if (entry == first ) {
423
- if (previous == null ) {
424
- entries [index ] = first .getNextInLookup ();
425
- } else {
426
- previous .setNextInLookup (first .getNextInLookup ());
427
- }
432
+ removeFromLookupChain (entries , index , first , previous );
428
433
break ;
429
434
}
430
435
0 commit comments