From be8d1bf029dac0e6d9dec0de3a77d5b33f420d2e Mon Sep 17 00:00:00 2001 From: Greg Burd Date: Fri, 29 Sep 2017 10:48:37 -0400 Subject: [PATCH] Use backingMap for the mutated key set (and save some space/overhead). --- src/main/java/net/helenus/core/AbstractEntityDraft.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/main/java/net/helenus/core/AbstractEntityDraft.java b/src/main/java/net/helenus/core/AbstractEntityDraft.java index 7054739..661e9b7 100644 --- a/src/main/java/net/helenus/core/AbstractEntityDraft.java +++ b/src/main/java/net/helenus/core/AbstractEntityDraft.java @@ -13,7 +13,6 @@ import net.helenus.mapping.MappingUtil; public abstract class AbstractEntityDraft implements Drafted { private final Map backingMap = new HashMap(); - private final Set mutatedSet = new HashSet(); private final MapExportable entity; private final Map entityMap; @@ -56,7 +55,6 @@ public abstract class AbstractEntityDraft implements Drafted { } backingMap.put(key, value); - mutatedSet.add(key); return value; } @@ -72,14 +70,12 @@ public abstract class AbstractEntityDraft implements Drafted { if (map.containsKey(key) && !value.equals(map.get(key))) { backingMap.put(key, value); - mutatedSet.add(key); return value; } return map.get(key); } else { backingMap.put(key, value); - mutatedSet.add(key); return null; } @@ -99,7 +95,6 @@ public abstract class AbstractEntityDraft implements Drafted { if (key != null) { Object value = backingMap.get(key); backingMap.put(key, null); - mutatedSet.add(key); return value; } return null; @@ -136,7 +131,7 @@ public abstract class AbstractEntityDraft implements Drafted { } else { combined = new HashMap(backingMap.size()); } - for (String key : mutatedSet) { + for (String key : mutated()) { combined.put(key, backingMap.get(key)); } return combined; @@ -144,7 +139,7 @@ public abstract class AbstractEntityDraft implements Drafted { @Override public Set mutated() { - return mutatedSet; + return backingMap.keySet(); } @Override