Skip to content

Commit a29779a

Browse files
committed
Use asSize in GetLengthNode
1 parent 4a95eb5 commit a29779a

File tree

1 file changed

+2
-4
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator

1 file changed

+2
-4
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/IteratorNodes.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
import com.oracle.graal.python.nodes.attributes.LookupAttributeInMRONode;
5656
import com.oracle.graal.python.nodes.call.special.CallUnaryMethodNode;
5757
import com.oracle.graal.python.nodes.object.IsBuiltinClassProfile;
58-
import com.oracle.graal.python.nodes.util.CastToJavaIntLossyNode;
5958
import com.oracle.graal.python.runtime.exception.PException;
6059
import com.oracle.truffle.api.dsl.Cached;
6160
import com.oracle.truffle.api.dsl.GenerateNodeFactory;
@@ -93,7 +92,6 @@ static int length(@SuppressWarnings({"unused"}) VirtualFrame frame, @SuppressWar
9392
int length(VirtualFrame frame, Object iterable,
9493
@CachedLibrary("iterable") PythonObjectLibrary plib,
9594
@CachedLibrary(limit = "3") PythonObjectLibrary toInt,
96-
@Cached CastToJavaIntLossyNode cast,
9795
@Cached("create(__LEN__)") LookupAttributeInMRONode lenNode,
9896
@Cached("create(__LENGTH_HINT__)") LookupAttributeInMRONode lenHintNode,
9997
@Cached CallUnaryMethodNode dispatchGetattribute,
@@ -112,7 +110,7 @@ int length(VirtualFrame frame, Object iterable,
112110
}
113111
if (len != null && len != PNotImplemented.NOT_IMPLEMENTED) {
114112
if (toInt.canBeIndex(len)) {
115-
int intLen = cast.execute(toInt.asIndex(len));
113+
int intLen = toInt.asSize(len);
116114
if (intLen < 0) {
117115
throw raiseNode.raise(TypeError, ErrorMessages.LEN_SHOULD_RETURN_MT_ZERO);
118116
}
@@ -132,7 +130,7 @@ int length(VirtualFrame frame, Object iterable,
132130
}
133131
if (len != null && len != PNotImplemented.NOT_IMPLEMENTED) {
134132
if (toInt.canBeIndex(len)) {
135-
int intLen = cast.execute(toInt.asIndex(len));
133+
int intLen = toInt.asSize(len);
136134
if (intLen < 0) {
137135
throw raiseNode.raise(TypeError, ErrorMessages.LENGTH_HINT_SHOULD_RETURN_MT_ZERO);
138136
}

0 commit comments

Comments
 (0)