74
74
import com .oracle .graal .python .annotations .ArgumentClinic .ClinicConversion ;
75
75
import com .oracle .graal .python .builtins .Builtin ;
76
76
import com .oracle .graal .python .builtins .CoreFunctions ;
77
+ import com .oracle .graal .python .builtins .Python3Core ;
77
78
import com .oracle .graal .python .builtins .PythonBuiltinClassType ;
78
79
import com .oracle .graal .python .builtins .PythonBuiltins ;
79
80
import com .oracle .graal .python .builtins .objects .PNone ;
117
118
import com .oracle .graal .python .nodes .util .CastToJavaIntExactNode ;
118
119
import com .oracle .graal .python .nodes .util .CastToJavaStringNode ;
119
120
import com .oracle .graal .python .runtime .PythonContext ;
120
- import com .oracle .graal .python .builtins .Python3Core ;
121
121
import com .oracle .graal .python .runtime .exception .PException ;
122
122
import com .oracle .graal .python .runtime .object .PythonObjectFactory ;
123
123
import com .oracle .truffle .api .CompilerDirectives ;
@@ -853,31 +853,9 @@ protected ArgumentClinicProvider getArgumentClinic() {
853
853
static PNone doGeneric (PDeque self , int idx , Object value ,
854
854
@ Cached NormalizeIndexCustomMessageNode normalizeIndexNode ) {
855
855
int normIdx = normalizeIndexNode .execute (idx , self .getSize (), ErrorMessages .DEQUE_INDEX_OUT_OF_RANGE );
856
- doSetItem ( self , normIdx , value );
856
+ self . setItem ( normIdx , value != PNone . NO_VALUE ? value : null );
857
857
return PNone .NONE ;
858
858
}
859
-
860
- @ TruffleBoundary
861
- static void doSetItem (PDeque self , int idx , Object value ) {
862
- assert 0 <= idx && idx < self .getSize ();
863
- int n = self .getSize () - idx - 1 ;
864
- Object [] savedItems = new Object [n ];
865
- for (int i = 0 ; i < savedItems .length ; i ++) {
866
- savedItems [i ] = self .pop ();
867
- }
868
- // this removes the item we want to replace
869
- self .pop ();
870
- assert self .getSize () == idx ;
871
- if (value != PNone .NO_VALUE ) {
872
- self .append (value );
873
- }
874
-
875
- // re-add saved items
876
- for (int i = savedItems .length - 1 ; i >= 0 ; i --) {
877
- self .append (savedItems [i ]);
878
- }
879
- assert value != PNone .NO_VALUE && self .getSize () == n + idx + 1 || value == PNone .NO_VALUE && self .getSize () == n + idx ;
880
- }
881
859
}
882
860
883
861
@ Builtin (name = __DELITEM__ , minNumOfPositionalArgs = 2 , parameterNames = {"$self" , "n" })
@@ -894,7 +872,7 @@ protected ArgumentClinicProvider getArgumentClinic() {
894
872
static PNone doGeneric (PDeque self , int idx ,
895
873
@ Cached NormalizeIndexCustomMessageNode normalizeIndexNode ) {
896
874
int normIdx = normalizeIndexNode .execute (idx , self .getSize (), ErrorMessages .DEQUE_INDEX_OUT_OF_RANGE );
897
- DequeSetItemNode . doSetItem ( self , normIdx , PNone . NO_VALUE );
875
+ self . setItem ( normIdx , null );
898
876
return PNone .NONE ;
899
877
}
900
878
}
0 commit comments