mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Use Data.equivalent() method in KeySearch.keyEquals() (because it could be specialized to perform more efficiently), and switch arguments in Data.bytesEquivalent() usages, so that the first Data instance is more likely to optimized for comparison
This commit is contained in:
@@ -34,7 +34,7 @@ import static net.openhft.chronicle.algo.bytes.Access.checkedRandomDataInputAcce
|
||||
* <p>In most cases, each particular value wraps either some object or some bytes. Object
|
||||
* is marshalled to bytes lazily on demand, and bytes are lazily deserialized to object,
|
||||
* accordingly.
|
||||
*
|
||||
*
|
||||
* @param <T> type of the accessed objects
|
||||
*/
|
||||
public interface Data<T> {
|
||||
|
||||
@@ -84,9 +84,7 @@ public abstract class KeySearch<K> {
|
||||
}
|
||||
|
||||
boolean keyEquals(long keySize, long keyOffset) {
|
||||
return inputKey.size() == keySize &&
|
||||
BytesUtil.bytesEqual(s.segmentBS, keyOffset,
|
||||
inputKey.bytes(), inputKey.offset(), keySize);
|
||||
return inputKey.size() == keySize && inputKey.equivalent(s.segmentBS, keyOffset);
|
||||
}
|
||||
|
||||
public boolean searchStatePresent() {
|
||||
|
||||
@@ -238,7 +238,7 @@ public interface MapMethods<K, V, R> {
|
||||
// as in putIfAbsent()/acquireUsing(), start with update lock:
|
||||
q.updateLock().lock();
|
||||
MapEntry<K, V> entry = q.entry();
|
||||
if (entry != null && bytesEquivalent(entry.value(), value)) {
|
||||
if (entry != null && bytesEquivalent(value, entry.value())) {
|
||||
q.remove(entry);
|
||||
return true;
|
||||
} else {
|
||||
@@ -298,7 +298,7 @@ public interface MapMethods<K, V, R> {
|
||||
// as in putIfAbsent()/acquireUsing(), start with update lock:
|
||||
q.updateLock().lock();
|
||||
MapEntry<K, V> entry = q.entry();
|
||||
if (entry != null && bytesEquivalent(((MapEntry<K, V>) entry).value(), oldValue)) {
|
||||
if (entry != null && bytesEquivalent(oldValue, entry.value())) {
|
||||
q.replaceValue(entry, newValue);
|
||||
return true;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user