forked from I2P_Developers/i2p.i2p
Data: Use Arrays.equals() directly, same as DataHelper.eq()
This commit is contained in:
@@ -12,6 +12,7 @@ package net.i2p.data;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Defines a certificate that can be attached to various I2P structures, such
|
||||
@@ -231,7 +232,7 @@ public class Certificate extends DataStructureImpl {
|
||||
if (object == this) return true;
|
||||
if ((object == null) || !(object instanceof Certificate)) return false;
|
||||
Certificate cert = (Certificate) object;
|
||||
return _type == cert.getCertificateType() && DataHelper.eq(_payload, cert.getPayload());
|
||||
return _type == cert.getCertificateType() && Arrays.equals(_payload, cert.getPayload());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -9,6 +9,8 @@ package net.i2p.data;
|
||||
*
|
||||
*/
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import net.i2p.crypto.DSAEngine;
|
||||
|
||||
/**
|
||||
@@ -108,7 +110,7 @@ public abstract class DatabaseEntry extends DataStructureImpl {
|
||||
public Hash getRoutingKey() {
|
||||
RoutingKeyGenerator gen = RoutingKeyGenerator.getInstance();
|
||||
byte[] mod = gen.getModData();
|
||||
if (!DataHelper.eq(mod, _routingKeyGenMod)) {
|
||||
if (!Arrays.equals(mod, _routingKeyGenMod)) {
|
||||
_currentRoutingKey = gen.getRoutingKey(getHash());
|
||||
_routingKeyGenMod = mod;
|
||||
}
|
||||
|
@@ -13,6 +13,7 @@ import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Arrays;
|
||||
|
||||
import net.i2p.crypto.SHA256Generator;
|
||||
|
||||
@@ -125,7 +126,7 @@ public class KeysAndCert extends DataStructureImpl {
|
||||
return
|
||||
DataHelper.eq(_signingKey, ident._signingKey)
|
||||
&& DataHelper.eq(_publicKey, ident._publicKey)
|
||||
&& DataHelper.eq(_padding, ident._padding)
|
||||
&& Arrays.equals(_padding, ident._padding)
|
||||
&& DataHelper.eq(_certificate, ident._certificate);
|
||||
}
|
||||
|
||||
|
@@ -12,6 +12,7 @@ package net.i2p.data;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Defines the actual payload of a message being delivered, including the
|
||||
@@ -108,8 +109,8 @@ public class Payload extends DataStructureImpl {
|
||||
if (object == this) return true;
|
||||
if ((object == null) || !(object instanceof Payload)) return false;
|
||||
Payload p = (Payload) object;
|
||||
return DataHelper.eq(_unencryptedData, p.getUnencryptedData())
|
||||
&& DataHelper.eq(_encryptedData, p.getEncryptedData());
|
||||
return Arrays.equals(_unencryptedData, p.getUnencryptedData())
|
||||
&& Arrays.equals(_encryptedData, p.getEncryptedData());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -9,6 +9,8 @@ package net.i2p.data;
|
||||
*
|
||||
*/
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import net.i2p.crypto.KeyGenerator;
|
||||
|
||||
/**
|
||||
@@ -56,7 +58,6 @@ public class PrivateKey extends SimpleDataStructure {
|
||||
/**
|
||||
* We assume the data has enough randomness in it, so use the last 4 bytes for speed.
|
||||
* Overridden since we use short exponents, so the first 227 bytes are all zero.
|
||||
* Not that we are storing PrivateKeys in any Sets or Maps anywhere.
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
@@ -72,6 +73,6 @@ public class PrivateKey extends SimpleDataStructure {
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) return true;
|
||||
if ((obj == null) || !(obj instanceof PrivateKey)) return false;
|
||||
return DataHelper.eq(_data, ((PrivateKey) obj)._data);
|
||||
return Arrays.equals(_data, ((PrivateKey) obj)._data);
|
||||
}
|
||||
}
|
||||
|
@@ -12,6 +12,7 @@ package net.i2p.data;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Arrays;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.Locale;
|
||||
import java.util.TimeZone;
|
||||
@@ -149,7 +150,7 @@ public class RoutingKeyGenerator {
|
||||
long now = _context.clock().now();
|
||||
setCalToPreviousMidnight(now);
|
||||
byte[] mod = generateModDataFromCal();
|
||||
boolean changed = !DataHelper.eq(_currentModData, mod);
|
||||
boolean changed = !Arrays.equals(_currentModData, mod);
|
||||
if (changed) {
|
||||
// add a day and store next midnight and mod data for convenience
|
||||
_cal.add(Calendar.DATE, 1);
|
||||
|
@@ -6,6 +6,7 @@ import java.io.InputStream;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
import net.i2p.I2PAppContext;
|
||||
@@ -120,7 +121,7 @@ public class SDSCache<V extends SimpleDataStructure> {
|
||||
rv = ref.get();
|
||||
else
|
||||
rv = null;
|
||||
if (rv != null && DataHelper.eq(data, rv.getData())) {
|
||||
if (rv != null && Arrays.equals(data, rv.getData())) {
|
||||
// found it, we don't need the data passed in any more
|
||||
SimpleByteCache.release(data);
|
||||
found = 1;
|
||||
|
@@ -7,6 +7,7 @@ package net.i2p.data;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Arrays;
|
||||
|
||||
import net.i2p.crypto.SHA256Generator;
|
||||
|
||||
@@ -183,6 +184,6 @@ public abstract class SimpleDataStructure extends DataStructureImpl {
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) return true;
|
||||
if ((obj == null) || !(obj instanceof SimpleDataStructure)) return false;
|
||||
return DataHelper.eq(_data, ((SimpleDataStructure) obj)._data);
|
||||
return Arrays.equals(_data, ((SimpleDataStructure) obj)._data);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user