From 9ad22e13e54566a293067b8708bff387682deb1b Mon Sep 17 00:00:00 2001 From: Reino Ruusu Date: Tue, 25 Feb 2020 18:32:21 +0200 Subject: [PATCH] Eliminate unnecessary storage of graph objects in map objects. gitlab #482 Change-Id: Id600bda6892857a376cd169219636dc0300763d4 --- .../simantics/objmap/graph/impl/Mapping.java | 29 ++++++++----------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/impl/Mapping.java b/bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/impl/Mapping.java index c2ecdf1b1..1589e9432 100644 --- a/bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/impl/Mapping.java +++ b/bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/impl/Mapping.java @@ -79,7 +79,7 @@ public class Mapping implements IMapping { link.type = type; link.domainElement = domainElement; domain.put(domainElement, link); - type.createDomain(g, new RangeToDomain(g), domainElement, link.rangeElement); + type.createDomain(g, new RangeToDomain(), domainElement, link.rangeElement); // TODO Should we do this only if the mapping is listening? domainModified(link); @@ -92,7 +92,7 @@ public class Mapping implements IMapping { link.type = type; link.rangeElement = rangeElement; range.put(rangeElement, link); - type.createRange(g, new DomainToRange(g), link.domainElement, rangeElement); + type.createRange(g, new DomainToRange(), link.domainElement, rangeElement); } Set domainSet = new AbstractSet() { @@ -173,10 +173,7 @@ public class Mapping implements IMapping { class DomainToRange implements IForwardMapping { - ReadGraph g; - - public DomainToRange(ReadGraph g) { - this.g = g; + public DomainToRange() { } @Override @@ -197,10 +194,10 @@ public class Mapping implements IMapping { link.domainModified = true; modifiedDomainLinks.add(link); domain.put(element, link); - createRange(g, link); + createRange(graph, link); } else if(link.type == null) - createRange(g, link); + createRange(graph, link); return link.rangeElement; } @@ -213,12 +210,10 @@ public class Mapping implements IMapping { class RangeToDomain extends DomainToRange implements IBackwardMapping { - WriteGraph g; - - public RangeToDomain(WriteGraph g) { - super(g); - this.g = g; + public RangeToDomain() { + super(); } + @Override public Domain inverseGet(Range element) { @@ -237,10 +232,10 @@ public class Mapping implements IMapping { link.rangeModified = true; modifiedRangeLinks.add(link); range.put(element, link); - createDomain(g, link); + createDomain(graph, link); } else if(link.type == null) - createDomain(g, link); + createDomain(graph, link); return link.domainElement; } @@ -265,7 +260,7 @@ public class Mapping implements IMapping { @Override public synchronized Collection updateDomain(WriteGraph g) throws MappingException { LOGGER.trace("Mapping.updateDomain"); - RangeToDomain map = new RangeToDomain(g); + RangeToDomain map = new RangeToDomain(); ArrayList updated = new ArrayList(); while(!modifiedRangeLinks.isEmpty()) { LOGGER.trace(" modifiedRangeLinks.size() = " + modifiedRangeLinks.size()); @@ -293,7 +288,7 @@ public class Mapping implements IMapping { @Override public synchronized Collection updateRange(ReadGraph g) throws MappingException { LOGGER.trace("Mapping.updateRange"); - DomainToRange map = new DomainToRange(g); + DomainToRange map = new DomainToRange(); ArrayList updated = new ArrayList(); while(!modifiedDomainLinks.isEmpty()) { LOGGER.trace(" modifiedDomainLinks.size() = " + modifiedDomainLinks.size()); -- 2.47.1