Skip to content

Commit 8168fe5

Browse files
committed
Remove SequenceStorage.equals
1 parent 6b1f8a4 commit 8168fe5

File tree

12 files changed

+7
-157
lines changed

12 files changed

+7
-157
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/list/PList.java

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
import com.oracle.graal.python.util.OverflowException;
3939
import com.oracle.truffle.api.CompilerAsserts;
4040
import com.oracle.truffle.api.CompilerDirectives;
41+
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
42+
import com.oracle.truffle.api.CompilerDirectives.ValueType;
4143
import com.oracle.truffle.api.dsl.Bind;
4244
import com.oracle.truffle.api.dsl.Cached;
4345
import com.oracle.truffle.api.dsl.Cached.Exclusive;
@@ -46,7 +48,6 @@
4648
import com.oracle.truffle.api.interop.UnsupportedMessageException;
4749
import com.oracle.truffle.api.library.ExportLibrary;
4850
import com.oracle.truffle.api.library.ExportMessage;
49-
import com.oracle.truffle.api.library.ExportMessage.Ignore;
5051
import com.oracle.truffle.api.nodes.Node;
5152
import com.oracle.truffle.api.object.Shape;
5253
import com.oracle.truffle.api.source.SourceSection;
@@ -70,12 +71,12 @@ public PList(Object cls, Shape instanceShape, SequenceStorage store, ListOrigin
7071
}
7172

7273
@Override
73-
public final SequenceStorage getSequenceStorage() {
74+
public SequenceStorage getSequenceStorage() {
7475
return store;
7576
}
7677

7778
@Override
78-
public final void setSequenceStorage(SequenceStorage newStorage) {
79+
public void setSequenceStorage(SequenceStorage newStorage) {
7980
this.store = newStorage;
8081
}
8182

@@ -85,25 +86,6 @@ public String toString() {
8586
return String.format("list(%s)", store);
8687
}
8788

88-
@Ignore
89-
@Override
90-
public final boolean equals(Object other) {
91-
if (!(other instanceof PList)) {
92-
return false;
93-
}
94-
if (this == other) {
95-
return true;
96-
}
97-
PList otherList = (PList) other;
98-
SequenceStorage otherStore = otherList.getSequenceStorage();
99-
return store.equals(otherStore);
100-
}
101-
102-
@Override
103-
public final int hashCode() {
104-
return super.hashCode();
105-
}
106-
10789
public ListOrigin getOrigin() {
10890
return origin;
10991
}
@@ -230,12 +212,12 @@ public interface ListOrigin {
230212
* to reach a size one larger than the current estimate to increase the estimate for new
231213
* lists.
232214
*/
233-
@CompilerDirectives.ValueType
234-
public static final class SizeEstimate {
215+
@ValueType
216+
final class SizeEstimate {
235217
private static final int NUM_DIGITS = 3;
236218
private static final int NUM_DIGITS_POW2 = 1 << NUM_DIGITS;
237219

238-
@CompilerDirectives.CompilationFinal private int shiftedStorageSizeEstimate;
220+
@CompilationFinal private int shiftedStorageSizeEstimate;
239221

240222
public SizeEstimate(int storageSizeEstimate) {
241223
assert storageSizeEstimate >= 0;

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/PTuple.java

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,11 @@
2525
*/
2626
package com.oracle.graal.python.builtins.objects.tuple;
2727

28-
import com.oracle.graal.python.builtins.PythonBuiltinClassType;
29-
import com.oracle.graal.python.nodes.ErrorMessages;
30-
import com.oracle.graal.python.nodes.PRaiseNode;
3128
import com.oracle.graal.python.runtime.sequence.PSequence;
3229
import com.oracle.graal.python.runtime.sequence.storage.MroSequenceStorage;
3330
import com.oracle.graal.python.runtime.sequence.storage.ObjectSequenceStorage;
3431
import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage;
3532
import com.oracle.truffle.api.CompilerAsserts;
36-
import com.oracle.truffle.api.CompilerDirectives;
3733
import com.oracle.truffle.api.interop.InteropLibrary;
3834
import com.oracle.truffle.api.interop.InvalidArrayIndexException;
3935
import com.oracle.truffle.api.interop.UnsupportedMessageException;
@@ -75,24 +71,6 @@ public void setSequenceStorage(SequenceStorage store) {
7571
this.store = store;
7672
}
7773

78-
@Override
79-
@ExportMessage.Ignore
80-
public boolean equals(Object other) {
81-
CompilerAsserts.neverPartOfCompilation();
82-
if (!(other instanceof PTuple)) {
83-
return false;
84-
}
85-
86-
PTuple otherTuple = (PTuple) other;
87-
return store.equals(otherTuple.store);
88-
}
89-
90-
@Override
91-
public int hashCode() {
92-
CompilerAsserts.neverPartOfCompilation();
93-
return super.hashCode();
94-
}
95-
9674
public long getHash() {
9775
return hash;
9876
}
@@ -101,12 +79,6 @@ public void setHash(long hash) {
10179
this.hash = hash;
10280
}
10381

104-
@SuppressWarnings({"static-method", "unused"})
105-
public static void setItem(int idx, Object value) {
106-
CompilerDirectives.transferToInterpreterAndInvalidate();
107-
throw PRaiseNode.raiseUncached(null, PythonBuiltinClassType.PTuple, ErrorMessages.OBJ_DOES_NOT_SUPPORT_ITEM_ASSIGMENT);
108-
}
109-
11082
@ExportMessage
11183
@SuppressWarnings("unused")
11284
public static boolean isArrayElementModifiable(PTuple self, long index) {

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

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -166,22 +166,6 @@ public Object getIndicativeValue() {
166166
return false;
167167
}
168168

169-
@Override
170-
public boolean equals(SequenceStorage other) {
171-
if (other.length() != length() || !(other instanceof BoolSequenceStorage)) {
172-
return false;
173-
}
174-
175-
boolean[] otherArray = ((BoolSequenceStorage) other).getInternalBoolArray();
176-
for (int i = 0; i < length(); i++) {
177-
if (values[i] != otherArray[i]) {
178-
return false;
179-
}
180-
}
181-
182-
return true;
183-
}
184-
185169
@Override
186170
public Object getInternalArrayObject() {
187171
return values;

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

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -199,22 +199,6 @@ public Object getIndicativeValue() {
199199
return 0;
200200
}
201201

202-
@Override
203-
public boolean equals(SequenceStorage other) {
204-
if (other.length() != length() || !(other instanceof ByteSequenceStorage)) {
205-
return false;
206-
}
207-
208-
byte[] otherArray = ((ByteSequenceStorage) other).getInternalByteArray();
209-
for (int i = 0; i < length(); i++) {
210-
if (values[i] != otherArray[i]) {
211-
return false;
212-
}
213-
}
214-
215-
return true;
216-
}
217-
218202
@Override
219203
public Object getInternalArrayObject() {
220204
return values;

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

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -178,22 +178,6 @@ public Object getIndicativeValue() {
178178
return .0;
179179
}
180180

181-
@Override
182-
public boolean equals(SequenceStorage other) {
183-
if (other.length() != length()) {
184-
return false;
185-
}
186-
187-
double[] otherArray = ((DoubleSequenceStorage) other).getInternalDoubleArray();
188-
for (int i = 0; i < length(); i++) {
189-
if (values[i] != otherArray[i]) {
190-
return false;
191-
}
192-
}
193-
194-
return true;
195-
}
196-
197181
@Override
198182
public Object getInternalArrayObject() {
199183
return values;

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,6 @@ public SequenceStorage getSliceInBound(int start, int stop, int step, int len) {
8888
return this;
8989
}
9090

91-
@Override
92-
public boolean equals(SequenceStorage other) {
93-
return other == EmptySequenceStorage.INSTANCE;
94-
}
95-
9691
@Override
9792
public ListStorageType getElementType() {
9893
return ListStorageType.Empty;

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

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -178,22 +178,6 @@ public Object getIndicativeValue() {
178178
return 0;
179179
}
180180

181-
@Override
182-
public boolean equals(SequenceStorage other) {
183-
if (other.length() != length() || !(other instanceof IntSequenceStorage)) {
184-
return false;
185-
}
186-
187-
int[] otherArray = ((IntSequenceStorage) other).getInternalIntArray();
188-
for (int i = 0; i < length(); i++) {
189-
if (values[i] != otherArray[i]) {
190-
return false;
191-
}
192-
}
193-
194-
return true;
195-
}
196-
197181
@Override
198182
public Object getInternalArrayObject() {
199183
return values;

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

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -188,22 +188,6 @@ public Object getIndicativeValue() {
188188
return 0;
189189
}
190190

191-
@Override
192-
public boolean equals(SequenceStorage other) {
193-
if (other.length() != length() || !(other instanceof LongSequenceStorage)) {
194-
return false;
195-
}
196-
197-
long[] otherArray = ((LongSequenceStorage) other).getInternalLongArray();
198-
for (int i = 0; i < length(); i++) {
199-
if (values[i] != otherArray[i]) {
200-
return false;
201-
}
202-
}
203-
204-
return true;
205-
}
206-
207191
@Override
208192
public Object getInternalArrayObject() {
209193
return values;

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,6 @@ public Object getIndicativeValue() {
177177
return null;
178178
}
179179

180-
@Override
181-
public boolean equals(SequenceStorage other) {
182-
Object[] otherArray = other.getInternalArray();
183-
return Arrays.equals(values, otherArray);
184-
}
185-
186180
@Override
187181
public Object getInternalArrayObject() {
188182
return values;

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,6 @@ public final SequenceStorage getSliceInBound(int start, int stop, int step, int
112112
throw CompilerDirectives.shouldNotReachHere();
113113
}
114114

115-
@Override
116-
public final boolean equals(SequenceStorage other) {
117-
throw CompilerDirectives.shouldNotReachHere();
118-
}
119-
120115
@Override
121116
public final SequenceStorage generalizeFor(Object value, SequenceStorage other) {
122117
throw CompilerDirectives.shouldNotReachHere();

0 commit comments

Comments
 (0)