Skip to content

Commit b515edc

Browse files
committed
Eclipse formatting and using more appropriate method for deleting item.
1 parent f036b69 commit b515edc

File tree

1 file changed

+22
-23
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/list

1 file changed

+22
-23
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/list/ListBuiltins.java

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -519,60 +519,60 @@ public PList insert(PList list, Object i, Object arg1) {
519519
@Builtin(name = "remove", fixedNumOfArguments = 2)
520520
@GenerateNodeFactory
521521
public abstract static class ListRemoveNode extends PythonBuiltinNode {
522-
522+
523523
private static String NOT_IN_LIST_MESSAGE = "list.index(x): x not in list";
524-
524+
525525
@Specialization(guards = "isIntStorage(list)")
526526
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++) {
529529
if (value == store.getIntItemNormalized(index)) {
530-
store.popInBound(index);
530+
store.delItemInBound(index);
531531
return PNone.NONE;
532532
}
533533
}
534534
throw raise(PythonErrorType.ValueError, NOT_IN_LIST_MESSAGE);
535535
}
536-
536+
537537
@Specialization(guards = "isLongStorage(list)")
538538
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++) {
541541
if (value == store.getLongItemNormalized(index)) {
542-
store.popInBound(index);
542+
store.delItemInBound(index);
543543
return PNone.NONE;
544544
}
545545
}
546546
throw raise(PythonErrorType.ValueError, NOT_IN_LIST_MESSAGE);
547547
}
548-
548+
549549
@Specialization(guards = "isLongStorage(list)")
550550
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++) {
553553
if (value == store.getLongItemNormalized(index)) {
554-
store.popInBound(index);
554+
store.delItemInBound(index);
555555
return PNone.NONE;
556556
}
557557
}
558558
throw raise(PythonErrorType.ValueError, NOT_IN_LIST_MESSAGE);
559559
}
560-
560+
561561
@Specialization(guards = "isDoubleStorage(list)")
562562
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++) {
565565
if (value == store.getDoubleItemNormalized(index)) {
566-
store.popInBound(index);
566+
store.delItemInBound(index);
567567
return PNone.NONE;
568568
}
569569
}
570570
throw raise(PythonErrorType.ValueError, NOT_IN_LIST_MESSAGE);
571571
}
572-
572+
573573
@Specialization(guards = "isNotSpecialCase(list, value)")
574574
public PNone remove(PList list, Object value,
575-
@Cached("create(__EQ__, __EQ__, __EQ__)") BinaryComparisonNode eqNode) {
575+
@Cached("create(__EQ__, __EQ__, __EQ__)") BinaryComparisonNode eqNode) {
576576
int len = list.len();
577577
for (int i = 0; i < len; i++) {
578578
Object object = list.getItem(i);
@@ -583,11 +583,10 @@ public PNone remove(PList list, Object value,
583583
}
584584
throw raise(PythonErrorType.ValueError, NOT_IN_LIST_MESSAGE);
585585
}
586-
586+
587587
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);
591590
}
592591
}
593592

0 commit comments

Comments
 (0)