summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLieven Lemiengre2011-09-14 03:29:06 (EDT)
committer Sebastian Zarnekow2011-10-09 12:17:56 (EDT)
commit85d3fe1cee726656a66a49634d98aed4a522f843 (patch)
treef720daba5a47461d6392e55892b9204773208070
parent0a875c7a60f5a38d60708cda8d74a09002de13b5 (diff)
downloadorg.eclipse.xtext-85d3fe1cee726656a66a49634d98aed4a522f843.zip
org.eclipse.xtext-85d3fe1cee726656a66a49634d98aed4a522f843.tar.gz
org.eclipse.xtext-85d3fe1cee726656a66a49634d98aed4a522f843.tar.bz2
improved filterByURI performance
Signed-off-by: Sebastian Zarnekow <Sebastian.Zarnekow@itemis.de>
-rw-r--r--plugins/org.eclipse.xtext/src/org/eclipse/xtext/resource/containers/StateBasedContainer.java19
-rw-r--r--plugins/org.eclipse.xtext/src/org/eclipse/xtext/resource/impl/ResourceDescriptionsBasedContainer.java7
2 files changed, 20 insertions, 6 deletions
diff --git a/plugins/org.eclipse.xtext/src/org/eclipse/xtext/resource/containers/StateBasedContainer.java b/plugins/org.eclipse.xtext/src/org/eclipse/xtext/resource/containers/StateBasedContainer.java
index 689c1e6..0ea7e71 100644
--- a/plugins/org.eclipse.xtext/src/org/eclipse/xtext/resource/containers/StateBasedContainer.java
+++ b/plugins/org.eclipse.xtext/src/org/eclipse/xtext/resource/containers/StateBasedContainer.java
@@ -9,7 +9,9 @@ package org.eclipse.xtext.resource.containers;
import static java.util.Collections.*;
+import java.util.Collection;
import java.util.Collections;
+import java.util.HashMap;
import java.util.Map;
import org.eclipse.emf.common.util.URI;
@@ -21,6 +23,8 @@ import org.eclipse.xtext.resource.IResourceDescription;
import org.eclipse.xtext.resource.IResourceDescriptions;
import org.eclipse.xtext.resource.impl.ResourceDescriptionsBasedContainer;
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
import com.google.common.collect.Maps;
/**
@@ -38,6 +42,21 @@ public class StateBasedContainer extends ResourceDescriptionsBasedContainer {
super(descriptions);
this.state = state;
}
+
+ @Override
+ protected Iterable<IEObjectDescription> filterByURI(Iterable<IEObjectDescription> unfiltered) {
+ return Iterables.filter(unfiltered, new Predicate<IEObjectDescription>() {
+ private Collection<URI> contents = null;
+
+ public boolean apply(IEObjectDescription input) {
+ if(contents == null) {
+ contents = state.getContents();
+ }
+ URI resourceURI = input.getEObjectURI().trimFragment();
+ return contents.contains(resourceURI);
+ }
+ });
+ }
@Override
public boolean hasResourceDescription(URI uri) {
diff --git a/plugins/org.eclipse.xtext/src/org/eclipse/xtext/resource/impl/ResourceDescriptionsBasedContainer.java b/plugins/org.eclipse.xtext/src/org/eclipse/xtext/resource/impl/ResourceDescriptionsBasedContainer.java
index 2fa455c..4e742ca 100644
--- a/plugins/org.eclipse.xtext/src/org/eclipse/xtext/resource/impl/ResourceDescriptionsBasedContainer.java
+++ b/plugins/org.eclipse.xtext/src/org/eclipse/xtext/resource/impl/ResourceDescriptionsBasedContainer.java
@@ -70,12 +70,7 @@ public class ResourceDescriptionsBasedContainer extends AbstractContainer implem
}
protected Iterable<IEObjectDescription> filterByURI(Iterable<IEObjectDescription> unfiltered) {
- return Iterables.filter(unfiltered, new Predicate<IEObjectDescription>() {
- public boolean apply(IEObjectDescription input) {
- URI resourceURI = input.getEObjectURI().trimFragment();
- return hasResourceDescription(resourceURI);
- }
- });
+ return unfiltered;
}
@Override