[Minor] Compacting memory on HashMap and HashSet usage

This commit is contained in:
Robert von Burg 2017-05-16 11:50:37 +02:00
parent 885e5ebf04
commit 428b589d47
5 changed files with 6 additions and 6 deletions

View File

@ -153,7 +153,7 @@ public abstract class GroupedParameterizedElement extends AbstractStrolchElement
*/ */
public void addParameter(String bagKey, Parameter<?> parameter) throws StrolchException { public void addParameter(String bagKey, Parameter<?> parameter) throws StrolchException {
if (this.parameterBagMap == null) { if (this.parameterBagMap == null) {
this.parameterBagMap = new HashMap<>(); this.parameterBagMap = new HashMap<>(1, 1.0F);
} }
ParameterBag bag = this.parameterBagMap.get(bagKey); ParameterBag bag = this.parameterBagMap.get(bagKey);
if (bag == null) { if (bag == null) {
@ -250,7 +250,7 @@ public abstract class GroupedParameterizedElement extends AbstractStrolchElement
*/ */
public void addParameterBag(ParameterBag bag) { public void addParameterBag(ParameterBag bag) {
if (this.parameterBagMap == null) { if (this.parameterBagMap == null) {
this.parameterBagMap = new HashMap<>(); this.parameterBagMap = new HashMap<>(1, 1.0F);
} }
if (this.parameterBagMap.containsKey(bag.getId())) { if (this.parameterBagMap.containsKey(bag.getId())) {

View File

@ -133,7 +133,7 @@ public abstract class ParameterizedElement extends AbstractStrolchElement {
*/ */
public void addParameter(Parameter<?> parameter) { public void addParameter(Parameter<?> parameter) {
if (this.parameterMap == null) { if (this.parameterMap == null) {
this.parameterMap = new HashMap<>(); this.parameterMap = new HashMap<>(1, 1.0F);
} }
if (this.parameterMap.containsKey(parameter.getId())) { if (this.parameterMap.containsKey(parameter.getId())) {

View File

@ -85,7 +85,7 @@ public class Resource extends AbstractStrolchRootElement implements StrolchRootE
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void addTimedState(StrolchTimedState<?> strolchTimedState) { public void addTimedState(StrolchTimedState<?> strolchTimedState) {
if (this.timedStateMap == null) { if (this.timedStateMap == null) {
this.timedStateMap = new HashMap<>(); this.timedStateMap = new HashMap<>(1, 1.0F);
} }
if (this.timedStateMap.containsKey(strolchTimedState.getId())) { if (this.timedStateMap.containsKey(strolchTimedState.getId())) {

View File

@ -38,7 +38,7 @@ public class PolicyDefs {
private Map<String, PolicyDef> policyDefMap; private Map<String, PolicyDef> policyDefMap;
public PolicyDefs() { public PolicyDefs() {
this.policyDefMap = new HashMap<>(0); this.policyDefMap = new HashMap<>(1, 1.0F);
} }
public void setParent(StrolchElement parent) { public void setParent(StrolchElement parent) {

View File

@ -114,7 +114,7 @@ public class SystemHelper {
sb.append(SystemHelper.getMaxMemory()); sb.append(SystemHelper.getMaxMemory());
sb.append(" / Used: "); //$NON-NLS-1$ sb.append(" / Used: "); //$NON-NLS-1$
sb.append(SystemHelper.getUsedMemory()); sb.append(SystemHelper.getUsedMemory());
sb.append(" / Free:"); //$NON-NLS-1$ sb.append(" / Free: "); //$NON-NLS-1$
sb.append(SystemHelper.getFreeMemory()); sb.append(SystemHelper.getFreeMemory());
return sb.toString(); return sb.toString();
} }