File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/range Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -339,17 +339,22 @@ protected static boolean allNone(PObjectSlice slice) {
339
339
return slice .getStart () == PNone .NONE && slice .getStop () == PNone .NONE && slice .getStep () == PNone .NONE ;
340
340
}
341
341
342
+ protected static boolean isNotSlice (Object value ) {
343
+ return !(value instanceof PSlice );
344
+ }
345
+
342
346
@ Specialization (guards = "allNone(slice)" )
343
347
Object doPRangeObj (PRange range , @ SuppressWarnings ("unused" ) PObjectSlice slice ) {
344
348
return range ;
345
349
}
346
350
347
- @ Specialization (guards = "canBeInteger(idx)" )
348
- Object doPRange (PIntRange primary , Object idx ) {
349
- return primary .getIntItemNormalized (normalize .execute (idx , primary .getIntLength ()));
351
+ @ Specialization (limit = "getCallSiteInlineCacheMaxDepth()" , guards = "isNotSlice(idx)" )
352
+ Object doPRange (PIntRange primary , Object idx ,
353
+ @ CachedLibrary (value = "idx" ) PythonObjectLibrary pol ) {
354
+ return primary .getIntItemNormalized (normalize .execute (pol .asSize (idx ), primary .getIntLength ()));
350
355
}
351
356
352
- @ Specialization (guards = "canBeInteger (idx)" )
357
+ @ Specialization (guards = "isNotSlice (idx)" )
353
358
Object doPRange (PBigRange self , Object idx ,
354
359
@ Cached CastToJavaBigIntegerNode toBigInt ) {
355
360
return factory ().createInt (self .getBigIntItemNormalized (computeBigRangeItem (self , idx , toBigInt )));
You can’t perform that action at this time.
0 commit comments