@@ -706,32 +706,18 @@ Object extend(VirtualFrame frame, PArray self, PSequence value,
706
706
@ Cached SequenceStorageNodes .GetItemScalarNode getItemNode ) {
707
707
SequenceStorage storage = getSequenceStorageNode .execute (value );
708
708
int storageLength = lenNode .execute (storage );
709
- boolean capacityEnsured = false ;
710
709
try {
711
710
self .resizeStorage (PythonUtils .addExact (self .getLength (), storageLength ));
712
- capacityEnsured = true ;
713
711
} catch (OverflowException e ) {
714
712
CompilerDirectives .transferToInterpreterAndInvalidate ();
715
- // Let it fail later, so that it fails in the same state as the generic
716
- // specialization
713
+ throw raise (MemoryError );
717
714
}
718
715
int length = self .getLength ();
719
716
for (int i = 0 ; i < storageLength ; i ++) {
720
717
// The whole extend is not atomic, just individual inserts are. That's the same as
721
718
// in CPython
722
- if (capacityEnsured ) {
723
- length ++;
724
- } else {
725
- try {
726
- length = PythonUtils .addExact (length , 1 );
727
- self .resizeStorage (length );
728
- } catch (OverflowException e ) {
729
- CompilerDirectives .transferToInterpreterAndInvalidate ();
730
- throw raise (MemoryError );
731
- }
732
- }
733
- putValueNode .execute (frame , self , length - 1 , getItemNode .execute (storage , i ));
734
- self .setLength (length );
719
+ putValueNode .execute (frame , self , length , getItemNode .execute (storage , i ));
720
+ self .setLength (++length );
735
721
}
736
722
737
723
return PNone .NONE ;
@@ -1101,24 +1087,21 @@ static Object byteswap1(@SuppressWarnings("unused") PArray self) {
1101
1087
return PNone .NONE ;
1102
1088
}
1103
1089
1104
- @ Specialization (guards = {"self.getFormat().bytesize == itemsize" , "itemsize == 2" })
1105
- static Object byteswap2 (PArray self ,
1106
- @ Cached ("self.getFormat().bytesize" ) int itemsize ) {
1107
- doByteSwapExploded (self , itemsize , self .getBuffer ());
1090
+ @ Specialization (guards = "self.getFormat().bytesize == 2" )
1091
+ static Object byteswap2 (PArray self ) {
1092
+ doByteSwapExploded (self , 2 , self .getBuffer ());
1108
1093
return PNone .NONE ;
1109
1094
}
1110
1095
1111
- @ Specialization (guards = {"self.getFormat().bytesize == itemsize" , "itemsize == 4" })
1112
- static Object byteswap4 (PArray self ,
1113
- @ Cached ("self.getFormat().bytesize" ) int itemsize ) {
1114
- doByteSwapExploded (self , itemsize , self .getBuffer ());
1096
+ @ Specialization (guards = "self.getFormat().bytesize == 4" )
1097
+ static Object byteswap4 (PArray self ) {
1098
+ doByteSwapExploded (self , 4 , self .getBuffer ());
1115
1099
return PNone .NONE ;
1116
1100
}
1117
1101
1118
- @ Specialization (guards = {"self.getFormat().bytesize == itemsize" , "itemsize == 8" })
1119
- static Object byteswap8 (PArray self ,
1120
- @ Cached ("self.getFormat().bytesize" ) int itemsize ) {
1121
- doByteSwapExploded (self , itemsize , self .getBuffer ());
1102
+ @ Specialization (guards = "self.getFormat().bytesize == 8" )
1103
+ static Object byteswap8 (PArray self ) {
1104
+ doByteSwapExploded (self , 8 , self .getBuffer ());
1122
1105
return PNone .NONE ;
1123
1106
}
1124
1107
0 commit comments