Committed by
Thomas Vachuska
ECMap: Avoid new mapvalue if raw values are equal
Change-Id: I84fa9bcada9ea9da1e0c43f61106a9d91fc60e62
Showing
1 changed file
with
4 additions
and
0 deletions
... | @@ -416,6 +416,10 @@ public class EventuallyConsistentMapImpl<K, V> | ... | @@ -416,6 +416,10 @@ public class EventuallyConsistentMapImpl<K, V> |
416 | MapValue<V> computedValue = items.compute(serializer.copy(key), (k, mv) -> { | 416 | MapValue<V> computedValue = items.compute(serializer.copy(key), (k, mv) -> { |
417 | previousValue.set(mv); | 417 | previousValue.set(mv); |
418 | V newRawValue = recomputeFunction.apply(key, mv == null ? null : mv.get()); | 418 | V newRawValue = recomputeFunction.apply(key, mv == null ? null : mv.get()); |
419 | + if (mv != null && Objects.equals(newRawValue, mv.get())) { | ||
420 | + // value was not updated | ||
421 | + return mv; | ||
422 | + } | ||
419 | MapValue<V> newValue = new MapValue<>(newRawValue, timestampProvider.apply(key, newRawValue)); | 423 | MapValue<V> newValue = new MapValue<>(newRawValue, timestampProvider.apply(key, newRawValue)); |
420 | if (mv == null || newValue.isNewerThan(mv)) { | 424 | if (mv == null || newValue.isNewerThan(mv)) { |
421 | updated.set(true); | 425 | updated.set(true); | ... | ... |
-
Please register or login to post a comment