Use backingMap for the mutated key set (and save some space/overhead).
This commit is contained in:
parent
1c37d817b6
commit
0e9d1086ed
1 changed files with 2 additions and 7 deletions
|
@ -13,7 +13,6 @@ import net.helenus.mapping.MappingUtil;
|
||||||
public abstract class AbstractEntityDraft<E> implements Drafted<E> {
|
public abstract class AbstractEntityDraft<E> implements Drafted<E> {
|
||||||
|
|
||||||
private final Map<String, Object> backingMap = new HashMap<String, Object>();
|
private final Map<String, Object> backingMap = new HashMap<String, Object>();
|
||||||
private final Set<String> mutatedSet = new HashSet<String>();
|
|
||||||
private final MapExportable entity;
|
private final MapExportable entity;
|
||||||
private final Map<String, Object> entityMap;
|
private final Map<String, Object> entityMap;
|
||||||
|
|
||||||
|
@ -56,7 +55,6 @@ public abstract class AbstractEntityDraft<E> implements Drafted<E> {
|
||||||
}
|
}
|
||||||
|
|
||||||
backingMap.put(key, value);
|
backingMap.put(key, value);
|
||||||
mutatedSet.add(key);
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,14 +70,12 @@ public abstract class AbstractEntityDraft<E> implements Drafted<E> {
|
||||||
|
|
||||||
if (map.containsKey(key) && !value.equals(map.get(key))) {
|
if (map.containsKey(key) && !value.equals(map.get(key))) {
|
||||||
backingMap.put(key, value);
|
backingMap.put(key, value);
|
||||||
mutatedSet.add(key);
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
return map.get(key);
|
return map.get(key);
|
||||||
} else {
|
} else {
|
||||||
backingMap.put(key, value);
|
backingMap.put(key, value);
|
||||||
mutatedSet.add(key);
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -99,7 +95,6 @@ public abstract class AbstractEntityDraft<E> implements Drafted<E> {
|
||||||
if (key != null) {
|
if (key != null) {
|
||||||
Object value = backingMap.get(key);
|
Object value = backingMap.get(key);
|
||||||
backingMap.put(key, null);
|
backingMap.put(key, null);
|
||||||
mutatedSet.add(key);
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -136,7 +131,7 @@ public abstract class AbstractEntityDraft<E> implements Drafted<E> {
|
||||||
} else {
|
} else {
|
||||||
combined = new HashMap<String, Object>(backingMap.size());
|
combined = new HashMap<String, Object>(backingMap.size());
|
||||||
}
|
}
|
||||||
for (String key : mutatedSet) {
|
for (String key : mutated()) {
|
||||||
combined.put(key, backingMap.get(key));
|
combined.put(key, backingMap.get(key));
|
||||||
}
|
}
|
||||||
return combined;
|
return combined;
|
||||||
|
@ -144,7 +139,7 @@ public abstract class AbstractEntityDraft<E> implements Drafted<E> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<String> mutated() {
|
public Set<String> mutated() {
|
||||||
return mutatedSet;
|
return backingMap.keySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue