mirror of
https://github.com/revanced/smali.git
synced 2025-05-08 10:24:31 +02:00
Add .hashcode and .equals to EncodedCatchHandler and EncodedTypeAddrPair, so that the TryListBuilder can build a unique hash to avoid duplicate EncodedCatchHandler entries
git-svn-id: https://smali.googlecode.com/svn/trunk@424 55b6fa8a-2a1e-11de-a435-ffa8d773f76a
This commit is contained in:
parent
0da75f71eb
commit
c604ed6c1a
@ -572,6 +572,39 @@ public class CodeItem extends Item<CodeItem> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
int hash = 0;
|
||||||
|
for (EncodedTypeAddrPair handler: handlers) {
|
||||||
|
hash = hash * 31 + handler.hashCode();
|
||||||
|
}
|
||||||
|
hash = hash * 31 + catchAllHandlerAddress;
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this==o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (o==null || !this.getClass().equals(o.getClass())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
EncodedCatchHandler other = (EncodedCatchHandler)o;
|
||||||
|
if (handlers.length != other.handlers.length || catchAllHandlerAddress != other.catchAllHandlerAddress) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i=0; i<handlers.length; i++) {
|
||||||
|
if (!handlers[i].equals(other.handlers[i])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class EncodedTypeAddrPair {
|
public static class EncodedTypeAddrPair {
|
||||||
@ -630,5 +663,23 @@ public class CodeItem extends Item<CodeItem> {
|
|||||||
out.writeUnsignedLeb128(handlerAddress);
|
out.writeUnsignedLeb128(handlerAddress);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return exceptionType.hashCode() * 31 + handlerAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this==o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (o==null || !this.getClass().equals(o.getClass())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
EncodedTypeAddrPair other = (EncodedTypeAddrPair)o;
|
||||||
|
return exceptionType == other.exceptionType && handlerAddress == other.handlerAddress;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user