Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlgoubet2012-10-03 14:59:28 +0000
committerlgoubet2012-10-03 14:59:28 +0000
commit70b2a9d510c392309f301719c7232683c71c6db3 (patch)
treec436f50baa37743f58795c23c8cb78777a59b7f8 /plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/logical
parentb3c87accaadd1a6b1e92aa9852fc76d57e9cf756 (diff)
downloadorg.eclipse.emf.compare-70b2a9d510c392309f301719c7232683c71c6db3.tar.gz
org.eclipse.emf.compare-70b2a9d510c392309f301719c7232683c71c6db3.tar.xz
org.eclipse.emf.compare-70b2a9d510c392309f301719c7232683c71c6db3.zip
Properly remove read-only resources
Diffstat (limited to 'plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/logical')
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/logical/EMFSynchronizationModel.java33
1 files changed, 16 insertions, 17 deletions
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/logical/EMFSynchronizationModel.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/logical/EMFSynchronizationModel.java
index af234cb2b..5523e01eb 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/logical/EMFSynchronizationModel.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/logical/EMFSynchronizationModel.java
@@ -174,11 +174,6 @@ public final class EMFSynchronizationModel {
final Set<IStorage> rightCopy = Sets.newLinkedHashSet(rightTraversal.getStorages());
final Set<IStorage> originCopy = Sets.newLinkedHashSet(originTraversal.getStorages());
- // TODO PERF We're iterating twice. Could probably be done in the latter loop
- removeReadOnly(leftTraversal.getStorages());
- removeReadOnly(rightTraversal.getStorages());
- removeReadOnly(originTraversal.getStorages());
-
for (IStorage left : leftCopy) {
final IStorage right = removeLikeNamedStorageFrom(left, rightCopy);
if (right != null && threeWay) {
@@ -192,21 +187,25 @@ public final class EMFSynchronizationModel {
} else if (right != null && binaryIdentical(left, right)) {
leftTraversal.getStorages().remove(left);
rightTraversal.getStorages().remove(right);
+ } else if (right == null) {
+ // This file has no match. remove it if read only
+ if (left.isReadOnly()) {
+ leftTraversal.getStorages().remove(left);
+ }
}
}
- }
- /**
- * This will iterate over the given set of storages and remove all "read-only" files from it.
- *
- * @param storages
- * The set of storages we are to filter.
- */
- private void removeReadOnly(Set<? extends IStorage> storages) {
- final Iterator<? extends IStorage> storageIt = storages.iterator();
- while (storageIt.hasNext()) {
- if (storageIt.next().isReadOnly()) {
- storageIt.remove();
+ for (IStorage right : rightCopy) {
+ // These have no match on left. Remove if read only
+ if (right.isReadOnly()) {
+ rightTraversal.getStorages().remove(right);
+ }
+ }
+
+ for (IStorage origin : originCopy) {
+ // These have no match on left and right. Remove if read only
+ if (origin.isReadOnly()) {
+ originTraversal.getStorages().remove(origin);
}
}
}

Back to the top