summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcbrun2013-05-07 11:35:01 (EDT)
committer cbrun2013-05-07 11:37:10 (EDT)
commit6350fbb63dc60973510cd27068da73767b9ee014 (patch)
treebf32b907b6bd99dbbcd9b7b1d30b85577a77320c
parentc9e03bd696f9006f4c75270995cf1c54fba47103 (diff)
downloadorg.eclipse.emf.compare-6350fbb63dc60973510cd27068da73767b9ee014.zip
org.eclipse.emf.compare-6350fbb63dc60973510cd27068da73767b9ee014.tar.gz
org.eclipse.emf.compare-6350fbb63dc60973510cd27068da73767b9ee014.tar.bz2
A cache for distance computation
During the content match, as model grows we often compute the same distance(a,b) or even an supposedly equivalent one : distance(b,a) This commit introduces a CachingDistance which wrapps another distance and cache the results for subsequent calls.
-rw-r--r--plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/match/DefaultMatchEngine.java6
-rw-r--r--plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/match/eobject/internal/ProximityIndex.java1
2 files changed, 4 insertions, 3 deletions
diff --git a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/match/DefaultMatchEngine.java b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/match/DefaultMatchEngine.java
index 68eaca2..2de5073 100644
--- a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/match/DefaultMatchEngine.java
+++ b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/match/DefaultMatchEngine.java
@@ -29,6 +29,7 @@ import org.eclipse.emf.compare.match.eobject.EditionDistance;
import org.eclipse.emf.compare.match.eobject.IEObjectMatcher;
import org.eclipse.emf.compare.match.eobject.IdentifierEObjectMatcher;
import org.eclipse.emf.compare.match.eobject.ProximityEObjectMatcher;
+import org.eclipse.emf.compare.match.eobject.internal.CachingDistance;
import org.eclipse.emf.compare.match.resource.IResourceMatcher;
import org.eclipse.emf.compare.match.resource.StrategyResourceMatcher;
import org.eclipse.emf.compare.scope.IComparisonScope;
@@ -376,9 +377,10 @@ public class DefaultMatchEngine implements IMatchEngine {
public static IEObjectMatcher createDefaultEObjectMatcher(UseIdentifiers useIDs) {
final IEObjectMatcher matcher;
final EditionDistance editionDistance = new EditionDistance();
+ final CachingDistance cachedDistance = new CachingDistance(editionDistance);
switch (useIDs) {
case NEVER:
- matcher = new ProximityEObjectMatcher(editionDistance);
+ matcher = new ProximityEObjectMatcher(cachedDistance);
break;
case ONLY:
matcher = new IdentifierEObjectMatcher();
@@ -387,7 +389,7 @@ public class DefaultMatchEngine implements IMatchEngine {
// fall through to default
default:
// Use an ID matcher, delegating to proximity when no ID is available
- final IEObjectMatcher contentMatcher = new ProximityEObjectMatcher(editionDistance);
+ final IEObjectMatcher contentMatcher = new ProximityEObjectMatcher(cachedDistance);
matcher = new IdentifierEObjectMatcher(contentMatcher);
break;
diff --git a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/match/eobject/internal/ProximityIndex.java b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/match/eobject/internal/ProximityIndex.java
index 87245e0..16e6447 100644
--- a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/match/eobject/internal/ProximityIndex.java
+++ b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/match/eobject/internal/ProximityIndex.java
@@ -88,7 +88,6 @@ public class ProximityIndex implements EObjectIndex {
this.rights = Lists.newArrayList();
this.origins = Lists.newArrayList();
this.scope = matcher;
-
}
/**