@@ -282,13 +282,32 @@ static HashingStorage setItemGeneric(EconomicMapStorage self, Object key, Object
282
282
}
283
283
}
284
284
285
+ @ TruffleBoundary
286
+ static boolean advance (MapCursor <DictKey , Object > cursor ) {
287
+ return cursor .advance ();
288
+ }
289
+
290
+ @ TruffleBoundary
291
+ static DictKey getDictKey (MapCursor <DictKey , Object > cursor ) {
292
+ return cursor .getKey ();
293
+ }
294
+
295
+ static Object getKey (MapCursor <DictKey , Object > cursor ) {
296
+ return getDictKey (cursor ).value ;
297
+ }
298
+
299
+ @ TruffleBoundary
300
+ static Object getValue (MapCursor <DictKey , Object > cursor ) {
301
+ return cursor .getValue ();
302
+ }
303
+
285
304
@ Override
286
305
@ ExportMessage
287
306
Object forEachUntyped (ForEachNode <Object > node , Object arg ) {
288
307
Object result = arg ;
289
308
MapCursor <DictKey , Object > cursor = map .getEntries ();
290
- while (cursor . advance ()) {
291
- result = node .execute (cursor . getKey (). value , result );
309
+ while (advance (cursor )) {
310
+ result = node .execute (getKey (cursor ) , result );
292
311
}
293
312
return result ;
294
313
}
@@ -325,8 +344,8 @@ static HashingStorage generic(EconomicMapStorage self, HashingStorage other,
325
344
@ CachedLibrary (limit = "2" ) HashingStorageLibrary lib ) {
326
345
HashingStorage result = other ;
327
346
MapCursor <DictKey , Object > cursor = self .map .getEntries ();
328
- while (cursor . advance ()) {
329
- result = lib .setItem (result , cursor . getKey (). value , cursor . getValue ());
347
+ while (advance (cursor )) {
348
+ result = lib .setItem (result , getKey (cursor ), getValue (cursor ));
330
349
}
331
350
return result ;
332
351
}
@@ -387,9 +406,9 @@ static HashingStorage clearWithSideEffect(EconomicMapStorage self,
387
406
Object [] entries = new Object [self .map .size () * 2 ];
388
407
MapCursor <DictKey , Object > cursor = self .map .getEntries ();
389
408
int i = 0 ;
390
- while (cursor . advance ()) {
391
- Object key = cursor . getKey (). value ;
392
- Object value = cursor . getValue ();
409
+ while (advance (cursor )) {
410
+ Object key = getKey (cursor ) ;
411
+ Object value = getValue (cursor );
393
412
entries [i ++] = hasSideEffect (key , lookup ) ? key : null ;
394
413
entries [i ++] = hasSideEffect (value , lookup ) ? value : null ;
395
414
}
@@ -423,9 +442,9 @@ static boolean equalSameType(EconomicMapStorage self, EconomicMapStorage other,
423
442
return false ;
424
443
}
425
444
MapCursor <DictKey , Object > cursor = self .map .getEntries ();
426
- while (cursor . advance ()) {
427
- Object otherValue = other .map .get (cursor . getKey ( ), compareLib1 , compareLib2 , findProfile , gotState , state );
428
- if (otherValue != null && !compareLib1 .equalsWithState (otherValue , cursor . getValue (), compareLib2 , state )) {
445
+ while (advance (cursor )) {
446
+ Object otherValue = other .map .get (getDictKey ( cursor ), compareLib1 , compareLib2 , findProfile , gotState , state );
447
+ if (otherValue != null && !compareLib1 .equalsWithState (otherValue , getValue (cursor ), compareLib2 , state )) {
429
448
return false ;
430
449
}
431
450
}
@@ -443,9 +462,9 @@ static boolean equalGeneric(EconomicMapStorage self, HashingStorage other, Threa
443
462
return false ;
444
463
}
445
464
MapCursor <DictKey , Object > cursor = self .map .getEntries ();
446
- while (cursor . advance ()) {
447
- Object otherValue = selflib .getItemWithState (self , cursor . getKey (). value , state );
448
- if (otherValue != null && !compareLib1 .equalsWithState (otherValue , cursor . getValue (), compareLib2 , state )) {
465
+ while (advance (cursor )) {
466
+ Object otherValue = selflib .getItemWithState (self , getKey (cursor ) , state );
467
+ if (otherValue != null && !compareLib1 .equalsWithState (otherValue , getValue (cursor ), compareLib2 , state )) {
449
468
return false ;
450
469
}
451
470
}
@@ -467,8 +486,8 @@ static int compareSameType(EconomicMapStorage self, EconomicMapStorage other, Th
467
486
return 1 ;
468
487
}
469
488
MapCursor <DictKey , Object > cursor = self .map .getEntries ();
470
- while (cursor . advance ()) {
471
- if (!other .map .containsKey (cursor . getKey ( ), lib , lib , findProfile , gotState , state )) {
489
+ while (advance (cursor )) {
490
+ if (!other .map .containsKey (getDictKey ( cursor ), lib , lib , findProfile , gotState , state )) {
472
491
return 1 ;
473
492
}
474
493
}
@@ -489,8 +508,8 @@ static int compareGeneric(EconomicMapStorage self, HashingStorage other, ThreadS
489
508
return 1 ;
490
509
}
491
510
MapCursor <DictKey , Object > cursor = self .map .getEntries ();
492
- while (cursor . advance ()) {
493
- if (!lib .hasKeyWithState (other , cursor . getKey (). value , state )) {
511
+ while (advance (cursor )) {
512
+ if (!lib .hasKeyWithState (other , getKey (cursor ) , state )) {
494
513
return 1 ;
495
514
}
496
515
}
@@ -512,9 +531,9 @@ static HashingStorage intersectSameType(EconomicMapStorage self, EconomicMapStor
512
531
@ CachedLibrary (limit = "2" ) PythonObjectLibrary lib ) {
513
532
EconomicMapStorage result = EconomicMapStorage .create ();
514
533
MapCursor <DictKey , Object > cursor = self .map .getEntries ();
515
- while (cursor . advance ()) {
516
- if (other .map .containsKey (cursor . getKey ( ), lib , lib , findProfile , gotState , state )) {
517
- result .map .put (cursor . getKey ( ), cursor . getValue ());
534
+ while (advance (cursor )) {
535
+ if (other .map .containsKey (getDictKey ( cursor ), lib , lib , findProfile , gotState , state )) {
536
+ result .map .put (getDictKey ( cursor ), getValue (cursor ));
518
537
}
519
538
}
520
539
return result ;
@@ -526,9 +545,9 @@ static HashingStorage intersectGeneric(EconomicMapStorage self, HashingStorage o
526
545
@ CachedLibrary ("other" ) HashingStorageLibrary hlib ) {
527
546
EconomicMapStorage result = EconomicMapStorage .create ();
528
547
MapCursor <DictKey , Object > cursor = self .map .getEntries ();
529
- while (cursor . advance ()) {
530
- if (hlib .hasKey (other , cursor . getKey (). value )) {
531
- result .map .put (cursor . getKey ( ), cursor . getValue ());
548
+ while (advance (cursor )) {
549
+ if (hlib .hasKey (other , getKey (cursor ) )) {
550
+ result .map .put (getDictKey ( cursor ), getValue (cursor ));
532
551
}
533
552
}
534
553
return result ;
@@ -545,9 +564,9 @@ static HashingStorage diffSameType(EconomicMapStorage self, EconomicMapStorage o
545
564
@ CachedLibrary (limit = "2" ) PythonObjectLibrary lib ) {
546
565
EconomicMapStorage result = EconomicMapStorage .create ();
547
566
MapCursor <DictKey , Object > cursor = self .map .getEntries ();
548
- while (cursor . advance ()) {
549
- if (!other .map .containsKey (cursor . getKey ( ), lib , lib , findProfile , gotState , state )) {
550
- result .map .put (cursor . getKey ( ), cursor . getValue ());
567
+ while (advance (cursor )) {
568
+ if (!other .map .containsKey (getDictKey ( cursor ), lib , lib , findProfile , gotState , state )) {
569
+ result .map .put (getDictKey ( cursor ), getValue (cursor ));
551
570
}
552
571
}
553
572
return result ;
@@ -559,9 +578,9 @@ static HashingStorage diffGeneric(EconomicMapStorage self, HashingStorage other,
559
578
@ CachedLibrary ("other" ) HashingStorageLibrary hlib ) {
560
579
EconomicMapStorage result = EconomicMapStorage .create ();
561
580
MapCursor <DictKey , Object > cursor = self .map .getEntries ();
562
- while (cursor . advance ()) {
563
- if (!hlib .hasKey (other , cursor . getKey (). value )) {
564
- result .map .put (cursor . getKey ( ), cursor . getValue ());
581
+ while (advance (cursor )) {
582
+ if (!hlib .hasKey (other , getKey (cursor ) )) {
583
+ result .map .put (getDictKey ( cursor ), getValue (cursor ));
565
584
}
566
585
}
567
586
return result ;
@@ -607,9 +626,9 @@ public String toString() {
607
626
builder .append ("map(size=" ).append (length ()).append (", {" );
608
627
String sep = "" ;
609
628
MapCursor <DictKey , Object > cursor = map .getEntries ();
610
- while (cursor . advance ()) {
629
+ while (advance (cursor )) {
611
630
builder .append (sep );
612
- builder .append ("(" ).append (cursor . getKey (). value ).append ("," ).append (cursor . getValue ()).append (")" );
631
+ builder .append ("(" ).append (getKey (cursor ) ).append ("," ).append (getValue (cursor )).append (")" );
613
632
sep = "," ;
614
633
}
615
634
builder .append ("})" );
0 commit comments