@@ -76,19 +76,21 @@ protected List<? extends NodeFactory<? extends PythonBuiltinBaseNode>> getNodeFa
76
76
public abstract static class NextNode extends PythonUnaryBuiltinNode {
77
77
78
78
@ Specialization
79
- public Object next (PArrayIterator self ,
79
+ Object next (PArrayIterator self ,
80
80
@ Cached ("createClassProfile()" ) ValueProfile itemTypeProfile ,
81
- @ Cached ("createNotNormalized()" ) SequenceStorageNodes .GetItemNode getItemNode ) {
82
- if (self .index < self .array .len ()) {
81
+ @ Cached ("createNotNormalized()" ) SequenceStorageNodes .GetItemNode getItemNode ,
82
+ @ Cached SequenceStorageNodes .LenNode lenNode ) {
83
+ SequenceStorage sequenceStorage = self .array .getSequenceStorage ();
84
+ if (self .index < lenNode .execute (sequenceStorage )) {
83
85
// TODO avoid boxing by getting the array's typecode and using primitive return
84
86
// types
85
- return itemTypeProfile .profile (getItemNode .execute (self . array . getSequenceStorage () , self .index ++));
87
+ return itemTypeProfile .profile (getItemNode .execute (sequenceStorage , self .index ++));
86
88
}
87
89
throw raise (StopIteration );
88
90
}
89
91
90
92
@ Specialization
91
- public int next (PIntegerSequenceIterator self ) {
93
+ int next (PIntegerSequenceIterator self ) {
92
94
if (!self .isExhausted () && self .index < self .sequence .length ()) {
93
95
return self .sequence .getIntItemNormalized (self .index ++);
94
96
}
@@ -97,7 +99,7 @@ public int next(PIntegerSequenceIterator self) {
97
99
}
98
100
99
101
@ Specialization
100
- public int next (PRangeIterator self ) {
102
+ int next (PRangeIterator self ) {
101
103
if (self .index < self .stop ) {
102
104
int value = self .index ;
103
105
self .index += self .step ;
@@ -107,7 +109,7 @@ public int next(PRangeIterator self) {
107
109
}
108
110
109
111
@ Specialization
110
- public int next (PRangeReverseIterator self ) {
112
+ int next (PRangeReverseIterator self ) {
111
113
if (self .index > self .stop ) {
112
114
int value = self .index ;
113
115
self .index -= self .step ;
@@ -117,7 +119,7 @@ public int next(PRangeReverseIterator self) {
117
119
}
118
120
119
121
@ Specialization
120
- public double next (PDoubleSequenceIterator self ) {
122
+ double next (PDoubleSequenceIterator self ) {
121
123
if (!self .isExhausted () && self .index < self .sequence .length ()) {
122
124
return self .sequence .getDoubleItemNormalized (self .index ++);
123
125
}
@@ -126,7 +128,7 @@ public double next(PDoubleSequenceIterator self) {
126
128
}
127
129
128
130
@ Specialization
129
- public long next (PLongSequenceIterator self ) {
131
+ long next (PLongSequenceIterator self ) {
130
132
if (!self .isExhausted () && self .index < self .sequence .length ()) {
131
133
return self .sequence .getLongItemNormalized (self .index ++);
132
134
}
0 commit comments