@@ -240,6 +240,23 @@ Object deleteLast(RubyHash hash, Object key,
240
240
return deleteKvAndGetV (hash , indexPos , lastKeyPos );
241
241
}
242
242
243
+ @ ExportMessage
244
+ RubyArray shift (RubyHash hash ,
245
+ @ Cached @ Shared HashingNodes .ToHash hashFunction ,
246
+ @ Cached @ Shared GetHashPosForKeyAtKvPosNode getHashPos ,
247
+ @ Cached @ Exclusive InlinedLoopConditionProfile nonNullKeyNotYetFound ,
248
+ @ Bind ("$node" ) Node node ) {
249
+ assert hash .size > 0 ;
250
+ int firstKeyPos = firstNonNullKeyPosFromBeginning (nonNullKeyNotYetFound , node );
251
+
252
+ Object key = kvStore [firstKeyPos ];
253
+ int keyHash = hashFunction .execute (key , hash .compareByIdentity );
254
+ int indexPos = getHashPos .execute (keyHash , firstKeyPos , index );
255
+ Object val = deleteKvAndGetV (hash , indexPos , firstKeyPos );
256
+
257
+ return ArrayHelpers .createArray (RubyContext .get (node ), RubyLanguage .get (node ), new Object []{ key , val });
258
+ }
259
+
243
260
@ ExportMessage
244
261
Object eachEntry (RubyHash hash , EachEntryCallback callback , Object state ,
245
262
@ Cached @ Exclusive InlinedConditionProfile keyNotNull ,
@@ -285,23 +302,6 @@ void replace(RubyHash hash, RubyHash dest,
285
302
dest .defaultValue = hash .defaultValue ;
286
303
}
287
304
288
- @ ExportMessage
289
- RubyArray shift (RubyHash hash ,
290
- @ Cached @ Shared HashingNodes .ToHash hashFunction ,
291
- @ Cached @ Shared GetHashPosForKeyAtKvPosNode getHashPos ,
292
- @ Cached @ Exclusive InlinedLoopConditionProfile nonNullKeyNotYetFound ,
293
- @ Bind ("$node" ) Node node ) {
294
- assert hash .size > 0 ;
295
- int firstKeyPos = firstNonNullKeyPosFromBeginning (nonNullKeyNotYetFound , node );
296
-
297
- Object key = kvStore [firstKeyPos ];
298
- int keyHash = hashFunction .execute (key , hash .compareByIdentity );
299
- int indexPos = getHashPos .execute (keyHash , firstKeyPos , index );
300
- Object val = deleteKvAndGetV (hash , indexPos , firstKeyPos );
301
-
302
- return ArrayHelpers .createArray (RubyContext .get (node ), RubyLanguage .get (node ), new Object []{ key , val });
303
- }
304
-
305
305
@ TruffleBoundary
306
306
@ ExportMessage
307
307
void rehash (RubyHash hash ,
0 commit comments