Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Vogel2019-06-18 09:16:23 +0000
committerLars Vogel2019-06-18 09:16:23 +0000
commitd5d2e9d7beddcef698e9dfd70de89e7d63c89524 (patch)
tree5c8344940169381dd24400dda2f16ea7f6daa99a /bundles/org.eclipse.team.ui
parent0af9ea510f9c3d39e0ad400aac48d22c54a95784 (diff)
downloadeclipse.platform.team-d5d2e9d7beddcef698e9dfd70de89e7d63c89524.tar.gz
eclipse.platform.team-d5d2e9d7beddcef698e9dfd70de89e7d63c89524.tar.xz
eclipse.platform.team-d5d2e9d7beddcef698e9dfd70de89e7d63c89524.zip
Use addAll, deleteAll instead of looping through a collectionI20190618-1805
Change-Id: If74eec05fb721ceeb1f9f8d7fbac9d68be6e767f Signed-off-by: Lars Vogel <Lars.Vogel@vogella.com>
Diffstat (limited to 'bundles/org.eclipse.team.ui')
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/Utils.java5
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/CompareInputChangeNotifier.java5
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceMergeActionHandler.java5
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceModelProviderOperation.java5
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceModelTraversalCalculator.java9
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/SynchronizationResourceMappingContext.java5
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/AbstractSynchronizeModelProvider.java13
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/CompositeModelProvider.java5
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeModelUpdateHandler.java4
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ExportProjectSetMainPage.java9
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/mapping/SynchronizationContentProvider.java9
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ModelSynchronizeParticipant.java5
12 files changed, 28 insertions, 51 deletions
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/Utils.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/Utils.java
index df2ad53da..7ea7072ce 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/Utils.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/Utils.java
@@ -18,6 +18,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.Iterator;
@@ -677,9 +678,7 @@ public class Utils {
ResourceTraversal[] traversals = element.getTraversals(ResourceMappingContext.LOCAL_CONTEXT, null);
for (ResourceTraversal traversal : traversals) {
IResource[] resourceArray = traversal.getResources();
- for (IResource resource : resourceArray) {
- resources.add(resource);
- }
+ Collections.addAll(resources, resourceArray);
}
} catch (CoreException e) {
TeamUIPlugin.log(new Status(IStatus.ERROR, TeamUIPlugin.ID, 0, "Error traversing resource mapping", e)); //$NON-NLS-1$
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/CompareInputChangeNotifier.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/CompareInputChangeNotifier.java
index 9c52a1eec..db7fc0229 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/CompareInputChangeNotifier.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/CompareInputChangeNotifier.java
@@ -14,6 +14,7 @@
package org.eclipse.team.internal.ui.mapping;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -133,9 +134,7 @@ public abstract class CompareInputChangeNotifier implements
InputChangeEvent changeEvent = (InputChangeEvent) event;
ICompareInput[] inputs = changeEvent.getChangedInputs();
synchronized (changedInputs) {
- for (ICompareInput input : inputs) {
- changedInputs.add(input);
- }
+ Collections.addAll(changedInputs, inputs);
}
}
break;
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceMergeActionHandler.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceMergeActionHandler.java
index 6a740b220..107cd6ee6 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceMergeActionHandler.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceMergeActionHandler.java
@@ -13,6 +13,7 @@
*******************************************************************************/
package org.eclipse.team.internal.ui.mapping;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@@ -72,9 +73,7 @@ public abstract class ResourceMergeActionHandler extends MergeActionHandler impl
ResourceTraversal[] traversals = mapping.getTraversals(ResourceMappingContext.LOCAL_CONTEXT, null);
for (ResourceTraversal traversal : traversals) {
IResource[] resources = traversal.getResources();
- for (IResource resource : resources) {
- roots.add(resource);
- }
+ Collections.addAll(roots, resources);
}
} catch (CoreException e) {
TeamUIPlugin.log(e);
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceModelProviderOperation.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceModelProviderOperation.java
index b8e8b386b..1dd1494f0 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceModelProviderOperation.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceModelProviderOperation.java
@@ -14,6 +14,7 @@
package org.eclipse.team.internal.ui.mapping;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -61,9 +62,7 @@ public abstract class ResourceModelProviderOperation extends SynchronizationOper
Set<IDiff> result = new HashSet<>();
for (Object pathOrElement : pathOrElements) {
IDiff[] diffs = getFileDeltas(pathOrElement);
- for (IDiff node : diffs) {
- result.add(node);
- }
+ Collections.addAll(result, diffs);
}
return result.toArray(new IDiff[result.size()]);
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceModelTraversalCalculator.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceModelTraversalCalculator.java
index aa1b7dd06..dd95a38d9 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceModelTraversalCalculator.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceModelTraversalCalculator.java
@@ -14,6 +14,7 @@
package org.eclipse.team.internal.ui.mapping;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@@ -161,13 +162,9 @@ public class ResourceModelTraversalCalculator {
private Object[] getTreeChildren(IResourceDiffTree diffTree, IResource resource, Object[] children) {
Set<Object> result = new HashSet<>();
- for (Object object : children) {
- result.add(object);
- }
+ Collections.addAll(result, children);
IResource[] setChildren = getChildren(diffTree, resource);
- for (IResource child : setChildren) {
- result.add(child);
- }
+ Collections.addAll(result, setChildren);
Object[] allChildren = result.toArray(new Object[result.size()]);
return allChildren;
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/SynchronizationResourceMappingContext.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/SynchronizationResourceMappingContext.java
index b4933656a..379c81672 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/SynchronizationResourceMappingContext.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/SynchronizationResourceMappingContext.java
@@ -13,6 +13,7 @@
*******************************************************************************/
package org.eclipse.team.internal.ui.mapping;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@@ -122,9 +123,7 @@ public final class SynchronizationResourceMappingContext extends
public IResource[] fetchMembers(IContainer container, IProgressMonitor monitor) throws CoreException {
Set<IResource> result = new HashSet<>();
IResource[] children = container.members();
- for (IResource resource : children) {
- result.add(resource);
- }
+ Collections.addAll(result, children);
IPath[] childPaths = context.getDiffTree().getChildren(container.getFullPath());
for (IPath path : childPaths) {
IDiff delta = context.getDiffTree().getDiff(path);
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/AbstractSynchronizeModelProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/AbstractSynchronizeModelProvider.java
index 2756ed5c1..2fb028413 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/AbstractSynchronizeModelProvider.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/AbstractSynchronizeModelProvider.java
@@ -14,6 +14,7 @@
package org.eclipse.team.internal.ui.synchronize;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@@ -414,15 +415,11 @@ public abstract class AbstractSynchronizeModelProvider implements ISynchronizeMo
protected IResource[] getExpandedResources() {
Set<IResource> expanded = new HashSet<>();
IResource[] savedExpansionState = getCachedResources(P_VIEWER_EXPANSION_STATE);
- for (IResource resource : savedExpansionState) {
- expanded.add(resource);
- }
+ Collections.addAll(expanded, savedExpansionState);
StructuredViewer viewer = getViewer();
Object[] objects = ((AbstractTreeViewer) viewer).getVisibleExpandedElements();
IResource[] currentExpansionState = getResources(objects);
- for (IResource resource : currentExpansionState) {
- expanded.add(resource);
- }
+ Collections.addAll(expanded, currentExpansionState);
return expanded.toArray(new IResource[expanded.size()]);
}
@@ -611,9 +608,7 @@ public abstract class AbstractSynchronizeModelProvider implements ISynchronizeMo
ISynchronizeModelElement[] elements = getModelObjects(resource);
// Only expand when there is one element per resource
if (elements.length == 1) {
- for (ISynchronizeModelElement element : elements) {
- checkedElements.add(element);
- }
+ Collections.addAll(checkedElements, elements);
}
}
if (!checkedElements.isEmpty())
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/CompositeModelProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/CompositeModelProvider.java
index dc57dd375..7ce1850d2 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/CompositeModelProvider.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/CompositeModelProvider.java
@@ -14,6 +14,7 @@
package org.eclipse.team.internal.ui.synchronize;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -78,9 +79,7 @@ public abstract class CompositeModelProvider extends AbstractSynchronizeModelPro
for (ISynchronizeModelProvider provider : providers) {
if (provider instanceof AbstractSynchronizeModelProvider) {
ISynchronizeModelElement[] elements = ((AbstractSynchronizeModelProvider)provider).getClosestExistingParents(resource);
- for (ISynchronizeModelElement element : elements) {
- result.add(element);
- }
+ Collections.addAll(result, elements);
}
}
return result.toArray(new ISynchronizeModelElement[result.size()]);
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeModelUpdateHandler.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeModelUpdateHandler.java
index 62c55d288..f9ad69236 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeModelUpdateHandler.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeModelUpdateHandler.java
@@ -182,9 +182,7 @@ public class SynchronizeModelUpdateHandler extends BackgroundEventHandler implem
handledResources.add(resource);
ISynchronizeModelElement[] elements = provider.getClosestExistingParents(delta.getResource());
if (elements != null && elements.length > 0) {
- for (ISynchronizeModelElement element : elements) {
- changes.add(element);
- }
+ Collections.addAll(changes, elements);
}
}
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ExportProjectSetMainPage.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ExportProjectSetMainPage.java
index 3a50b8739..04c8b274f 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ExportProjectSetMainPage.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ExportProjectSetMainPage.java
@@ -16,6 +16,7 @@ package org.eclipse.team.internal.ui.wizards;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@@ -382,9 +383,7 @@ public class ExportProjectSetMainPage extends TeamWizardPage {
IWorkingSet workingSet = (IWorkingSet) temp;
if (event.getChecked()){
IAdaptable[] elements1 = workingSet.getElements();
- for (IAdaptable element : elements1) {
- selectedProjects.add(element);
- }
+ Collections.addAll(selectedProjects, elements1);
} else {
IAdaptable[] elements2 = workingSet.getElements();
for (IAdaptable element : elements2) {
@@ -415,9 +414,7 @@ public class ExportProjectSetMainPage extends TeamWizardPage {
tableViewer.setAllChecked(true);
selectedProjects.removeAll(selectedProjects);
Object[] checked = tableViewer.getCheckedElements();
- for (Object c : checked) {
- selectedProjects.add(c);
- }
+ Collections.addAll(selectedProjects, checked);
updateEnablement();
});
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/mapping/SynchronizationContentProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/mapping/SynchronizationContentProvider.java
index 32cddb510..759e401f8 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/mapping/SynchronizationContentProvider.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/mapping/SynchronizationContentProvider.java
@@ -14,6 +14,7 @@
package org.eclipse.team.ui.mapping;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -504,12 +505,8 @@ public abstract class SynchronizationContentProvider implements ICommonContentPr
if (children.length == 0)
return setChildren;
Set<Object> result = new HashSet<>(children.length);
- for (Object c : children) {
- result.add(c);
- }
- for (IResource s : setChildren) {
- result.add(s);
- }
+ Collections.addAll(result, children);
+ Collections.addAll(result, setChildren);
return result.toArray();
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ModelSynchronizeParticipant.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ModelSynchronizeParticipant.java
index ca6d731bb..d58d58b73 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ModelSynchronizeParticipant.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ModelSynchronizeParticipant.java
@@ -15,6 +15,7 @@ package org.eclipse.team.ui.synchronize;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import org.eclipse.compare.structuremergeviewer.ICompareInput;
@@ -519,9 +520,7 @@ public class ModelSynchronizeParticipant extends
ISynchronizationCompareAdapter adapter = Utils.getCompareAdapter(provider);
if (adapter != null) {
ResourceMapping[] mappings = adapter.restore(memento.getChild(CTX_MODEL_PROVIDER_MAPPINGS));
- for (ResourceMapping mapping : mappings) {
- result.add(mapping);
- }
+ Collections.addAll(result, mappings);
}
} catch (CoreException e) {
TeamUIPlugin.log(e);

Back to the top