@@ -519,60 +519,60 @@ public PList insert(PList list, Object i, Object arg1) {
519
519
@ Builtin (name = "remove" , fixedNumOfArguments = 2 )
520
520
@ GenerateNodeFactory
521
521
public abstract static class ListRemoveNode extends PythonBuiltinNode {
522
-
522
+
523
523
private static String NOT_IN_LIST_MESSAGE = "list.index(x): x not in list" ;
524
-
524
+
525
525
@ Specialization (guards = "isIntStorage(list)" )
526
526
public PNone removeInt (PList list , int value ) {
527
- IntSequenceStorage store = (IntSequenceStorage )list .getSequenceStorage ();
528
- for (int index = 0 ; index < store .length (); index ++) {
527
+ IntSequenceStorage store = (IntSequenceStorage ) list .getSequenceStorage ();
528
+ for (int index = 0 ; index < store .length (); index ++) {
529
529
if (value == store .getIntItemNormalized (index )) {
530
- store .popInBound (index );
530
+ store .delItemInBound (index );
531
531
return PNone .NONE ;
532
532
}
533
533
}
534
534
throw raise (PythonErrorType .ValueError , NOT_IN_LIST_MESSAGE );
535
535
}
536
-
536
+
537
537
@ Specialization (guards = "isLongStorage(list)" )
538
538
public PNone removeLong (PList list , int value ) {
539
- LongSequenceStorage store = (LongSequenceStorage )list .getSequenceStorage ();
540
- for (int index = 0 ; index < store .length (); index ++) {
539
+ LongSequenceStorage store = (LongSequenceStorage ) list .getSequenceStorage ();
540
+ for (int index = 0 ; index < store .length (); index ++) {
541
541
if (value == store .getLongItemNormalized (index )) {
542
- store .popInBound (index );
542
+ store .delItemInBound (index );
543
543
return PNone .NONE ;
544
544
}
545
545
}
546
546
throw raise (PythonErrorType .ValueError , NOT_IN_LIST_MESSAGE );
547
547
}
548
-
548
+
549
549
@ Specialization (guards = "isLongStorage(list)" )
550
550
public PNone removeLong (PList list , long value ) {
551
- LongSequenceStorage store = (LongSequenceStorage )list .getSequenceStorage ();
552
- for (int index = 0 ; index < store .length (); index ++) {
551
+ LongSequenceStorage store = (LongSequenceStorage ) list .getSequenceStorage ();
552
+ for (int index = 0 ; index < store .length (); index ++) {
553
553
if (value == store .getLongItemNormalized (index )) {
554
- store .popInBound (index );
554
+ store .delItemInBound (index );
555
555
return PNone .NONE ;
556
556
}
557
557
}
558
558
throw raise (PythonErrorType .ValueError , NOT_IN_LIST_MESSAGE );
559
559
}
560
-
560
+
561
561
@ Specialization (guards = "isDoubleStorage(list)" )
562
562
public PNone removeDouble (PList list , double value ) {
563
- DoubleSequenceStorage store = (DoubleSequenceStorage )list .getSequenceStorage ();
564
- for (int index = 0 ; index < store .length (); index ++) {
563
+ DoubleSequenceStorage store = (DoubleSequenceStorage ) list .getSequenceStorage ();
564
+ for (int index = 0 ; index < store .length (); index ++) {
565
565
if (value == store .getDoubleItemNormalized (index )) {
566
- store .popInBound (index );
566
+ store .delItemInBound (index );
567
567
return PNone .NONE ;
568
568
}
569
569
}
570
570
throw raise (PythonErrorType .ValueError , NOT_IN_LIST_MESSAGE );
571
571
}
572
-
572
+
573
573
@ Specialization (guards = "isNotSpecialCase(list, value)" )
574
574
public PNone remove (PList list , Object value ,
575
- @ Cached ("create(__EQ__, __EQ__, __EQ__)" ) BinaryComparisonNode eqNode ) {
575
+ @ Cached ("create(__EQ__, __EQ__, __EQ__)" ) BinaryComparisonNode eqNode ) {
576
576
int len = list .len ();
577
577
for (int i = 0 ; i < len ; i ++) {
578
578
Object object = list .getItem (i );
@@ -583,11 +583,10 @@ public PNone remove(PList list, Object value,
583
583
}
584
584
throw raise (PythonErrorType .ValueError , NOT_IN_LIST_MESSAGE );
585
585
}
586
-
586
+
587
587
protected boolean isNotSpecialCase (PList list , Object value ) {
588
- return !((PGuards .isIntStorage (list ) && value instanceof Integer )
589
- || (PGuards .isLongStorage (list ) && (value instanceof Integer || value instanceof Long ))
590
- || PGuards .isDoubleStorage (list ) && value instanceof Double );
588
+ return !((PGuards .isIntStorage (list ) && value instanceof Integer ) || (PGuards .isLongStorage (list ) && (value instanceof Integer || value instanceof Long )) ||
589
+ PGuards .isDoubleStorage (list ) && value instanceof Double );
591
590
}
592
591
}
593
592
0 commit comments