Skip to content

Commit b337bd5

Browse files
committed
style: improving style
1 parent cf11d3e commit b337bd5

File tree

6 files changed

+33
-49
lines changed

6 files changed

+33
-49
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/json/JSONScannerBuiltins.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,6 @@
55
*/
66
package com.oracle.graal.python.builtins.modules.json;
77

8-
import static com.oracle.graal.python.nodes.SpecialMethodNames.J___CALL__;
9-
import static com.oracle.graal.python.util.PythonUtils.toTruffleStringUncached;
10-
import static com.oracle.graal.python.util.PythonUtils.tsLiteral;
11-
12-
import java.math.BigInteger;
13-
import java.util.List;
14-
158
import com.oracle.graal.python.PythonLanguage;
169
import com.oracle.graal.python.annotations.ArgumentClinic;
1710
import com.oracle.graal.python.builtins.Builtin;
@@ -23,7 +16,6 @@
2316
import com.oracle.graal.python.builtins.objects.common.EconomicMapStorage;
2417
import com.oracle.graal.python.builtins.objects.common.HashingStorage;
2518
import com.oracle.graal.python.builtins.objects.common.HashingStorageNodes.HashingStorageSetItem;
26-
import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes.InsertItemArrayBasedStorageNode;
2719
import com.oracle.graal.python.builtins.objects.dict.PDict;
2820
import com.oracle.graal.python.builtins.objects.floats.FloatUtils;
2921
import com.oracle.graal.python.builtins.objects.tuple.PTuple;
@@ -53,6 +45,13 @@
5345
import com.oracle.truffle.api.object.Shape;
5446
import com.oracle.truffle.api.strings.TruffleString;
5547

48+
import java.math.BigInteger;
49+
import java.util.List;
50+
51+
import static com.oracle.graal.python.nodes.SpecialMethodNames.J___CALL__;
52+
import static com.oracle.graal.python.util.PythonUtils.toTruffleStringUncached;
53+
import static com.oracle.graal.python.util.PythonUtils.tsLiteral;
54+
5655
@CoreFunctions(extendClasses = PythonBuiltinClassType.JSONScanner)
5756
public final class JSONScannerBuiltins extends PythonBuiltins {
5857

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/sequence/storage/ArrayBasedSequenceStorage.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@
4040
*/
4141
package com.oracle.graal.python.runtime.sequence.storage;
4242

43+
import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes;
44+
import com.oracle.truffle.api.CompilerAsserts;
45+
4346
public abstract class ArrayBasedSequenceStorage extends SequenceStorage {
4447

4548
public abstract Object getInternalArrayObject();
@@ -68,4 +71,19 @@ protected static int capacityFor(int length) throws ArithmeticException {
6871
public void minimizeCapacity() {
6972
capacity = length;
7073
}
74+
75+
@Override
76+
public String toString() {
77+
CompilerAsserts.neverPartOfCompilation();
78+
StringBuilder str = new StringBuilder(getClass().getSimpleName()).append('[');
79+
int len = length > 10 ? 10 : length;
80+
for (int i = 0; i < len; i++) {
81+
str.append(i == 0 ? "" : ", ");
82+
str.append(SequenceStorageNodes.GetItemScalarNode.executeUncached(this, i));
83+
}
84+
if (length > 10) {
85+
str.append("...").append('(').append(length).append(')');
86+
}
87+
return str.append(']').toString();
88+
}
7189
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/sequence/storage/ByteSequenceStorage.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,10 @@
2525
*/
2626
package com.oracle.graal.python.runtime.sequence.storage;
2727

28-
import static com.oracle.graal.python.runtime.exception.PythonErrorType.TypeError;
29-
import static com.oracle.graal.python.runtime.exception.PythonErrorType.ValueError;
30-
3128
import java.nio.ByteOrder;
3229
import java.util.Arrays;
3330

3431
import com.oracle.graal.python.builtins.objects.buffer.PythonBufferAccessLibrary;
35-
import com.oracle.graal.python.nodes.ErrorMessages;
36-
import com.oracle.graal.python.nodes.PRaiseNode;
3732
import com.oracle.graal.python.util.PythonUtils;
3833
import com.oracle.truffle.api.ArrayUtils;
3934
import com.oracle.truffle.api.CompilerDirectives;

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/sequence/storage/LongSequenceStorage.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,10 @@
2525
*/
2626
package com.oracle.graal.python.runtime.sequence.storage;
2727

28-
import java.math.BigInteger;
29-
import java.util.Arrays;
30-
3128
import com.oracle.truffle.api.CompilerDirectives;
3229

30+
import java.util.Arrays;
31+
3332
public final class LongSequenceStorage extends ArrayBasedSequenceStorage {
3433

3534
private long[] values;

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/sequence/storage/SequenceStorage.java

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@
2525
*/
2626
package com.oracle.graal.python.runtime.sequence.storage;
2727

28-
import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes.GetItemScalarNode;
29-
import com.oracle.truffle.api.CompilerAsserts;
30-
3128
public abstract class SequenceStorage {
3229

3330
public enum StorageType {
@@ -41,20 +38,12 @@ public enum StorageType {
4138
Generic;
4239

4340
public boolean generalizesFrom(StorageType other) {
44-
switch (this) {
45-
case Uninitialized:
46-
case Empty:
47-
return false;
48-
case Boolean:
49-
case Byte:
50-
case Double:
51-
case Int:
52-
return other == Uninitialized || other == Empty || other == Byte;
53-
case Long:
54-
return other == Uninitialized || other == Empty || other == Byte || other == Int;
55-
default:
56-
return true;
57-
}
41+
return switch (this) {
42+
case Uninitialized, Empty -> false;
43+
case Boolean, Byte, Double, Int -> other == Uninitialized || other == Empty || other == Byte;
44+
case Long -> other == Uninitialized || other == Empty || other == Byte || other == Int;
45+
default -> true;
46+
};
5847
}
5948
}
6049

@@ -83,19 +72,4 @@ public final int getCapacity() {
8372
public abstract StorageType getElementType();
8473

8574
public abstract Object getIndicativeValue();
86-
87-
@Override
88-
public String toString() {
89-
CompilerAsserts.neverPartOfCompilation();
90-
StringBuilder str = new StringBuilder(getClass().getSimpleName()).append('[');
91-
int len = length > 10 ? 10 : length;
92-
for (int i = 0; i < len; i++) {
93-
str.append(i == 0 ? "" : ", ");
94-
str.append(GetItemScalarNode.executeUncached(this, i));
95-
}
96-
if (length > 10) {
97-
str.append("...").append('(').append(length).append(')');
98-
}
99-
return str.append(']').toString();
100-
}
10175
}

mx.graalpython/copyrights/overrides

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,6 @@ graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/formatti
694694
graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/formatting/TextFormatter.java,jython.copyright
695695
graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/object/PythonObjectFactory.java,zippy.copyright
696696
graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/sequence/PSequence.java,zippy.copyright
697-
graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/sequence/storage/BasicSequenceStorage.java,zippy.copyright
698697
graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/sequence/storage/BoolSequenceStorage.java,zippy.copyright
699698
graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/sequence/storage/ByteSequenceStorage.java,zippy.copyright
700699
graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/sequence/storage/DoubleSequenceStorage.java,zippy.copyright

0 commit comments

Comments
 (0)