Skip to content

Commit c070147

Browse files
committed
Fix lenght->length typo
1 parent ecc9835 commit c070147

File tree

13 files changed

+97
-97
lines changed

13 files changed

+97
-97
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ArrayModuleBuiltins.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,10 @@ PArray arraySequenceInitializer(VirtualFrame frame, Object cls, String typeCode,
217217
@Cached SequenceStorageNodes.GetItemScalarNode getItemNode) {
218218
BufferFormat format = getFormatChecked(typeCode);
219219
SequenceStorage storage = getSequenceStorageNode.execute(initializer);
220-
int lenght = lenNode.execute(storage);
220+
int length = lenNode.execute(storage);
221221
try {
222-
PArray array = getFactory().createArray(cls, typeCode, format, lenght);
223-
for (int i = 0; i < lenght; i++) {
222+
PArray array = getFactory().createArray(cls, typeCode, format, length);
223+
for (int i = 0; i < length; i++) {
224224
putValueNode.execute(frame, array, i, getItemNode.execute(storage, i));
225225
}
226226
return array;
@@ -260,7 +260,7 @@ PArray arrayIteratorInitializer(VirtualFrame frame, Object cls, String typeCode,
260260
putValueNode.execute(frame, array, length - 1, nextValue);
261261
}
262262

263-
array.setLenght(length);
263+
array.setLength(length);
264264
return array;
265265
}
266266

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/CodecsModuleBuiltins.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -882,11 +882,11 @@ public void replace(int skipInput, char[] chars) {
882882
}
883883

884884
@TruffleBoundary
885-
public void replace(int skipInput, char[] chars, int offset, int lenght) {
885+
public void replace(int skipInput, char[] chars, int offset, int length) {
886886
while (outputBuffer.remaining() < chars.length) {
887887
grow();
888888
}
889-
outputBuffer.put(chars, offset, lenght);
889+
outputBuffer.put(chars, offset, length);
890890
inputBuffer.position(inputBuffer.position() + skipInput);
891891
}
892892

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/array/ArrayBuiltins.java

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,9 @@ Object concat(PArray self, int value) {
171171
int newLength = Math.max(PythonUtils.multiplyExact(self.getLength(), value), 0);
172172
int itemsize = self.getFormat().bytesize;
173173
PArray newArray = factory().createArray(self.getFormatStr(), self.getFormat(), newLength);
174-
int segmentLenght = self.getLength() * itemsize;
174+
int segmentLength = self.getLength() * itemsize;
175175
for (int i = 0; i < value; i++) {
176-
PythonUtils.arraycopy(self.getBuffer(), 0, newArray.getBuffer(), segmentLenght * i, segmentLenght);
176+
PythonUtils.arraycopy(self.getBuffer(), 0, newArray.getBuffer(), segmentLength * i, segmentLength);
177177
}
178178
return newArray;
179179
} catch (OverflowException e) {
@@ -201,10 +201,10 @@ Object concat(PArray self, int value) {
201201
try {
202202
int newLength = Math.max(PythonUtils.multiplyExact(self.getLength(), value), 0);
203203
int itemsize = self.getFormat().bytesize;
204-
int segmentLenght = self.getLength() * itemsize;
204+
int segmentLength = self.getLength() * itemsize;
205205
self.resize(newLength);
206206
for (int i = 0; i < value; i++) {
207-
PythonUtils.arraycopy(self.getBuffer(), 0, self.getBuffer(), segmentLenght * i, segmentLenght);
207+
PythonUtils.arraycopy(self.getBuffer(), 0, self.getBuffer(), segmentLength * i, segmentLength);
208208
}
209209
return self;
210210
} catch (OverflowException e) {
@@ -470,7 +470,7 @@ Object setitem(PArray self, PSlice slice, PArray other,
470470
@Cached ConditionProfile sameArrayProfile,
471471
@Cached ConditionProfile simpleStepProfile,
472472
@Cached ConditionProfile complexDeleteProfile,
473-
@Cached ConditionProfile differentLenghtProfile,
473+
@Cached ConditionProfile differentLengthProfile,
474474
@Cached ConditionProfile growProfile,
475475
@Cached ConditionProfile stepAssignProfile,
476476
@Cached SliceLiteralNode.SliceUnpack sliceUnpack,
@@ -489,7 +489,7 @@ Object setitem(PArray self, PSlice slice, PArray other,
489489
PythonUtils.arraycopy(other.getBuffer(), 0, sourceBuffer, 0, sourceBuffer.length);
490490
}
491491
if (simpleStepProfile.profile(step == 1)) {
492-
if (differentLenghtProfile.profile(sliceLength != needed)) {
492+
if (differentLengthProfile.profile(sliceLength != needed)) {
493493
if (growProfile.profile(sliceLength < needed)) {
494494
if (stop < start) {
495495
stop = start;
@@ -568,7 +568,7 @@ static Object delitem(PArray self, PSlice slice,
568568
PythonUtils.arraycopy(self.getBuffer(), (cur + 1) * itemsize, self.getBuffer(), (cur - offset) * itemsize, (step - 1) * itemsize);
569569
}
570570
PythonUtils.arraycopy(self.getBuffer(), (cur + 1) * itemsize, self.getBuffer(), (cur - offset) * itemsize, (length - cur - 1) * itemsize);
571-
self.setLenght(length - sliceLength);
571+
self.setLength(length - sliceLength);
572572
}
573573
}
574574
return PNone.NONE;
@@ -690,7 +690,7 @@ Object extend(PArray self, PArray value) {
690690
int itemsize = self.getFormat().bytesize;
691691
self.ensureCapacity(newLength);
692692
PythonUtils.arraycopy(value.getBuffer(), 0, self.getBuffer(), self.getLength() * itemsize, value.getLength() * itemsize);
693-
self.setLenght(newLength);
693+
self.setLength(newLength);
694694
return PNone.NONE;
695695
} catch (OverflowException e) {
696696
CompilerDirectives.transferToInterpreterAndInvalidate();
@@ -705,33 +705,33 @@ Object extend(VirtualFrame frame, PArray self, PSequence value,
705705
@Cached SequenceStorageNodes.LenNode lenNode,
706706
@Cached SequenceStorageNodes.GetItemScalarNode getItemNode) {
707707
SequenceStorage storage = getSequenceStorageNode.execute(value);
708-
int storageLenght = lenNode.execute(storage);
708+
int storageLength = lenNode.execute(storage);
709709
boolean capacityEnsured = false;
710710
try {
711-
self.ensureCapacity(PythonUtils.addExact(self.getLength(), storageLenght));
711+
self.ensureCapacity(PythonUtils.addExact(self.getLength(), storageLength));
712712
capacityEnsured = true;
713713
} catch (OverflowException e) {
714714
CompilerDirectives.transferToInterpreterAndInvalidate();
715715
// Let it fail later, so that it fails in the same state as the generic
716716
// specialization
717717
}
718-
int lenght = self.getLength();
719-
for (int i = 0; i < storageLenght; i++) {
718+
int length = self.getLength();
719+
for (int i = 0; i < storageLength; i++) {
720720
// The whole extend is not atomic, just individual inserts are. That's the same as
721721
// in CPython
722722
if (capacityEnsured) {
723-
lenght++;
723+
length++;
724724
} else {
725725
try {
726-
lenght = PythonUtils.addExact(lenght, 1);
727-
self.ensureCapacity(lenght);
726+
length = PythonUtils.addExact(length, 1);
727+
self.ensureCapacity(length);
728728
} catch (OverflowException e) {
729729
CompilerDirectives.transferToInterpreterAndInvalidate();
730730
throw raise(MemoryError);
731731
}
732732
}
733-
putValueNode.execute(frame, self, lenght - 1, getItemNode.execute(storage, i));
734-
self.setLenght(lenght);
733+
putValueNode.execute(frame, self, length - 1, getItemNode.execute(storage, i));
734+
self.setLength(length);
735735
}
736736

737737
return PNone.NONE;
@@ -744,7 +744,7 @@ Object extend(VirtualFrame frame, PArray self, Object value,
744744
@Cached GetNextNode nextNode,
745745
@Cached IsBuiltinClassProfile errorProfile) {
746746
Object iter = lib.getIteratorWithFrame(value, frame);
747-
int lenght = self.getLength();
747+
int length = self.getLength();
748748
while (true) {
749749
Object nextValue;
750750
try {
@@ -756,14 +756,14 @@ Object extend(VirtualFrame frame, PArray self, Object value,
756756
// The whole extend is not atomic, just individual inserts are. That's the same as
757757
// in CPython
758758
try {
759-
lenght = PythonUtils.addExact(lenght, 1);
760-
self.ensureCapacity(lenght);
759+
length = PythonUtils.addExact(length, 1);
760+
self.ensureCapacity(length);
761761
} catch (OverflowException e) {
762762
CompilerDirectives.transferToInterpreterAndInvalidate();
763763
throw raise(MemoryError);
764764
}
765-
putValueNode.execute(frame, self, lenght - 1, nextValue);
766-
self.setLenght(lenght);
765+
putValueNode.execute(frame, self, length - 1, nextValue);
766+
self.setLength(length);
767767
}
768768

769769
return PNone.NONE;
@@ -867,9 +867,9 @@ Object frombytes(PArray self, Object buffer,
867867
if (bufferLength % itemsize != 0) {
868868
throw raise(ValueError, "bytes length not a multiple of item size");
869869
}
870-
int newLenght = PythonUtils.addExact(oldSize, bufferLength / itemsize);
870+
int newLength = PythonUtils.addExact(oldSize, bufferLength / itemsize);
871871
byte[] bufferBytes = lib.getBufferBytes(buffer);
872-
self.resize(newLenght);
872+
self.resize(newLength);
873873
PythonUtils.arraycopy(bufferBytes, 0, self.getBuffer(), oldSize * itemsize, bufferLength);
874874
} catch (UnsupportedMessageException e) {
875875
throw CompilerDirectives.shouldNotReachHere();
@@ -902,11 +902,11 @@ Object fromfile(VirtualFrame frame, PArray self, Object file, int n,
902902
int nbytes = n * itemsize;
903903
Object readResult = lib.lookupAndCallRegularMethod(file, frame, "read", nbytes);
904904
if (readResult instanceof PBytes) {
905-
int readLenght = lib.length(readResult);
905+
int readLength = lib.length(readResult);
906906
fromBytesNode.execute(frame, self, readResult);
907907
// It would make more sense to check this before the frombytes call, but CPython
908908
// does it this way
909-
if (readLenght != nbytes) {
909+
if (readLength != nbytes) {
910910
notEnoughBytesProfile.enter();
911911
throw raise(EOFError, "read() didn't return enough bytes");
912912
}
@@ -934,13 +934,13 @@ Object fromlist(VirtualFrame frame, PArray self, PList list,
934934
@Cached ArrayNodes.PutValueNode putValueNode) {
935935
try {
936936
SequenceStorage storage = getSequenceStorageNode.execute(list);
937-
int lenght = lenNode.execute(storage);
938-
int newLength = PythonUtils.addExact(self.getLength(), lenght);
937+
int length = lenNode.execute(storage);
938+
int newLength = PythonUtils.addExact(self.getLength(), length);
939939
self.ensureCapacity(newLength);
940-
for (int i = 0; i < lenght; i++) {
940+
for (int i = 0; i < length; i++) {
941941
putValueNode.execute(frame, self, self.getLength() + i, getItemScalarNode.execute(storage, i));
942942
}
943-
self.setLenght(newLength);
943+
self.setLength(newLength);
944944
return PNone.NONE;
945945
} catch (OverflowException e) {
946946
CompilerDirectives.transferToInterpreterAndInvalidate();
@@ -986,16 +986,16 @@ abstract static class FromUnicodeNode extends PythonBinaryClinicBuiltinNode {
986986
Object fromunicode(VirtualFrame frame, PArray self, String str,
987987
@Cached ArrayNodes.PutValueNode putValueNode) {
988988
try {
989-
int lenght = PString.codePointCount(str, 0, str.length());
990-
int newLength = PythonUtils.addExact(self.getLength(), lenght);
989+
int length = PString.codePointCount(str, 0, str.length());
990+
int newLength = PythonUtils.addExact(self.getLength(), length);
991991
self.ensureCapacity(newLength);
992-
for (int i = 0, index = 0; i < lenght; index++) {
992+
for (int i = 0, index = 0; i < length; index++) {
993993
int cpCount = PString.charCount(PString.codePointAt(str, i));
994994
String value = PString.substring(str, i, i + cpCount);
995995
putValueNode.execute(frame, self, self.getLength() + index, value);
996996
i += cpCount;
997997
}
998-
self.setLenght(newLength);
998+
self.setLength(newLength);
999999
return PNone.NONE;
10001000
} catch (OverflowException e) {
10011001
CompilerDirectives.transferToInterpreterAndInvalidate();

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/array/PArray.java

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -44,22 +44,22 @@
4444
public final class PArray extends PythonBuiltinObject {
4545
private BufferFormat format;
4646
private String formatStr;
47-
private int lenght;
47+
private int length;
4848
private byte[] buffer;
4949

5050
public PArray(Object clazz, Shape instanceShape, String formatStr, BufferFormat format) {
5151
super(clazz, instanceShape);
5252
this.formatStr = formatStr;
5353
this.format = format;
54-
this.lenght = 0;
54+
this.length = 0;
5555
this.buffer = new byte[0];
5656
}
5757

5858
public PArray(Object clazz, Shape instanceShape, String formatStr, BufferFormat format, int length) throws OverflowException {
5959
super(clazz, instanceShape);
6060
this.formatStr = formatStr;
6161
this.format = format;
62-
this.lenght = length;
62+
this.length = length;
6363
this.buffer = new byte[PythonUtils.multiplyExact(length, format.bytesize)];
6464
}
6565

@@ -76,17 +76,17 @@ public byte[] getBuffer() {
7676
}
7777

7878
public int getLength() {
79-
return lenght;
79+
return length;
8080
}
8181

82-
public void setLenght(int lenght) {
83-
assert lenght >= 0;
84-
this.lenght = lenght;
82+
public void setLength(int length) {
83+
assert length >= 0;
84+
this.length = length;
8585
}
8686

8787
private int computeNewSize(int newLength, int itemsize) throws OverflowException {
8888
// Overallocation using the same formula as CPython
89-
int newSize = ((newLength >> 4) + (lenght < 8 ? 3 : 7) + newLength) * itemsize;
89+
int newSize = ((newLength >> 4) + (length < 8 ? 3 : 7) + newLength) * itemsize;
9090
if (newSize / itemsize < newLength) {
9191
throw OverflowException.INSTANCE;
9292
}
@@ -103,36 +103,36 @@ public void ensureCapacity(int newLength) throws OverflowException {
103103
}
104104
}
105105

106-
public void resize(int newLenght) throws OverflowException {
107-
ensureCapacity(newLenght);
108-
lenght = newLenght;
106+
public void resize(int newLength) throws OverflowException {
107+
ensureCapacity(newLength);
108+
length = newLength;
109109
}
110110

111111
public void shift(int from, int by) throws OverflowException {
112-
assert from >= 0 && from <= lenght;
112+
assert from >= 0 && from <= length;
113113
assert by >= 0;
114-
int newLength = PythonUtils.addExact(lenght, by);
114+
int newLength = PythonUtils.addExact(length, by);
115115
int itemsize = format.bytesize;
116116
if (buffer.length / itemsize < newLength) {
117117
byte[] newBuffer = new byte[computeNewSize(newLength, itemsize)];
118118
PythonUtils.arraycopy(buffer, 0, newBuffer, 0, from * itemsize);
119-
PythonUtils.arraycopy(buffer, from * itemsize, newBuffer, (from + by) * itemsize, (lenght - from) * itemsize);
119+
PythonUtils.arraycopy(buffer, from * itemsize, newBuffer, (from + by) * itemsize, (length - from) * itemsize);
120120
buffer = newBuffer;
121121
} else {
122-
PythonUtils.arraycopy(buffer, from * itemsize, buffer, (from + by) * itemsize, (lenght - from) * itemsize);
122+
PythonUtils.arraycopy(buffer, from * itemsize, buffer, (from + by) * itemsize, (length - from) * itemsize);
123123
}
124-
lenght = newLength;
124+
length = newLength;
125125
}
126126

127127
public void delSlice(int at, int count) {
128128
assert count >= 0;
129-
assert at + count <= lenght;
130-
int newLength = lenght - count;
129+
assert at + count <= length;
130+
int newLength = length - count;
131131
assert newLength >= 0;
132132
// TODO shrink?
133133
int itemsize = format.bytesize;
134-
PythonUtils.arraycopy(buffer, (at + count) * itemsize, buffer, at * itemsize, (lenght - at - count) * itemsize);
135-
lenght = newLength;
134+
PythonUtils.arraycopy(buffer, (at + count) * itemsize, buffer, at * itemsize, (length - at - count) * itemsize);
135+
length = newLength;
136136
}
137137

138138
@ExportMessage
@@ -153,7 +153,7 @@ byte[] getBufferBytes() {
153153

154154
@ExportMessage
155155
int getBufferLength() {
156-
return lenght * format.bytesize;
156+
return length * format.bytesize;
157157
}
158158

159159
public enum MachineFormat {

0 commit comments

Comments
 (0)