Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Vogel2019-06-18 05:16:32 -0400
committerLars Vogel2019-06-18 05:16:32 -0400
commit784c9608a760e3ffac6d43c77cdde0bc2f5f8760 (patch)
tree8908c7607dd1853447ca433c5faeac41ce3b137c
parent3e59edd77535744f1ee0a23a8db5be99d7d3f8c9 (diff)
downloadeclipse.platform.text-784c9608a760e3ffac6d43c77cdde0bc2f5f8760.tar.gz
eclipse.platform.text-784c9608a760e3ffac6d43c77cdde0bc2f5f8760.tar.xz
eclipse.platform.text-784c9608a760e3ffac6d43c77cdde0bc2f5f8760.zip
Use addAll, deleteAll instead of looping through a collectionI20190623-1800I20190621-1800I20190620-1800I20190620-0130I20190619-1820I20190619-1800
Change-Id: I35edd6a934a0f65f357a54e710c77c190706bb45 Signed-off-by: Lars Vogel <Lars.Vogel@vogella.com>
-rw-r--r--org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/SortingTest.java5
-rw-r--r--org.eclipse.search/new search/org/eclipse/search/ui/text/AbstractTextSearchViewPage.java9
-rw-r--r--org.eclipse.text/src/org/eclipse/jface/text/TextUtilities.java4
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SelectResourcesBlock.java9
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractMarkerAnnotationModel.java3
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindNextAction.java4
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceDialog.java7
7 files changed, 16 insertions, 25 deletions
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/SortingTest.java b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/SortingTest.java
index ca15cbd9e..9c4ee634f 100644
--- a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/SortingTest.java
+++ b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/SortingTest.java
@@ -17,6 +17,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import org.junit.Before;
@@ -55,9 +56,7 @@ public class SortingTest {
Object[] elements= result.getElements();
for (Object element : elements) {
Match[] matches = result.getMatches(element);
- for (Match matche : matches) {
- allMatches.add(matche);
- }
+ Collections.addAll(allMatches, matches);
}
// now remove them and readd them in reverse order
result.removeAll();
diff --git a/org.eclipse.search/new search/org/eclipse/search/ui/text/AbstractTextSearchViewPage.java b/org.eclipse.search/new search/org/eclipse/search/ui/text/AbstractTextSearchViewPage.java
index 55932b916..d5b28d11d 100644
--- a/org.eclipse.search/new search/org/eclipse/search/ui/text/AbstractTextSearchViewPage.java
+++ b/org.eclipse.search/new search/org/eclipse/search/ui/text/AbstractTextSearchViewPage.java
@@ -15,6 +15,7 @@
package org.eclipse.search.ui.text;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@@ -1352,18 +1353,14 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch
private void collectAllMatches(HashSet<Match> set, Object[] elements) {
for (Object element : elements) {
Match[] matches = getDisplayedMatches(element);
- for (Match match : matches) {
- set.add(match);
- }
+ Collections.addAll(set, matches);
}
}
private void collectAllMatchesBelow(AbstractTextSearchResult result, Set<Match> set, ITreeContentProvider cp, Object[] elements) {
for (Object element : elements) {
Match[] matches = getDisplayedMatches(element);
- for (Match match : matches) {
- set.add(match);
- }
+ Collections.addAll(set, matches);
Object[] children = cp.getChildren(element);
collectAllMatchesBelow(result, set, cp, children);
}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/TextUtilities.java b/org.eclipse.text/src/org/eclipse/jface/text/TextUtilities.java
index c9afe8dd1..f778e7a95 100644
--- a/org.eclipse.text/src/org/eclipse/jface/text/TextUtilities.java
+++ b/org.eclipse.text/src/org/eclipse/jface/text/TextUtilities.java
@@ -13,6 +13,7 @@
*******************************************************************************/
package org.eclipse.jface.text;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -459,8 +460,7 @@ public class TextUtilities {
IDocumentPartitionerExtension2 extension2= (IDocumentPartitionerExtension2) p;
String[] c= extension2.getManagingPositionCategories();
if (c != null) {
- for (String element : c)
- categories.add(element);
+ Collections.addAll(categories, c);
}
}
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SelectResourcesBlock.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SelectResourcesBlock.java
index cc409450f..fe63c9378 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SelectResourcesBlock.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SelectResourcesBlock.java
@@ -15,6 +15,7 @@ package org.eclipse.ui.internal.editors.text;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -416,9 +417,7 @@ class SelectResourcesBlock implements ICheckStateListener, ISelectionChangedList
@Override
public void filterElements(Object[] elements) throws InterruptedException {
- for (Object element : elements) {
- returnValue.add(element);
- }
+ Collections.addAll(returnValue, elements);
}
};
@@ -697,9 +696,7 @@ class SelectResourcesBlock implements ICheckStateListener, ISelectionChangedList
Object[] listItems= listContentProvider.getElements(treeElement);
List<Object> listItemsChecked= new ArrayList<>();
- for (int i= 0; i < listItems.length; ++i) {
- listItemsChecked.add(listItems[i]);
- }
+ Collections.addAll(listItemsChecked, listItems);
checkedStateStore.put(treeElement, listItemsChecked);
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractMarkerAnnotationModel.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractMarkerAnnotationModel.java
index 49612303d..83c7f9f3e 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractMarkerAnnotationModel.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractMarkerAnnotationModel.java
@@ -532,8 +532,7 @@ public abstract class AbstractMarkerAnnotationModel extends AnnotationModel impl
}
}
- for (int i= 0; i < toBeDeleted.size(); i++)
- fMarkerUpdaterSpecifications.remove(toBeDeleted.get(i));
+ fMarkerUpdaterSpecifications.removeAll(toBeDeleted);
}
/**
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindNextAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindNextAction.java
index d247e6f48..8e037e803 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindNextAction.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindNextAction.java
@@ -16,6 +16,7 @@ package org.eclipse.ui.texteditor;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import java.util.ResourceBundle;
import java.util.regex.PatternSyntaxException;
@@ -357,8 +358,7 @@ public class FindNextAction extends ResourceAction implements IUpdate {
String[] findHistory= s.getArray("findhistory"); //$NON-NLS-1$
if (findHistory != null) {
fFindHistory.clear();
- for (int i= 0; i < findHistory.length; i++)
- fFindHistory.add(findHistory[i]);
+ Collections.addAll(fFindHistory, findHistory);
}
}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceDialog.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceDialog.java
index 75ce29104..00860cd97 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceDialog.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceDialog.java
@@ -15,6 +15,7 @@
package org.eclipse.ui.texteditor;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -1828,16 +1829,14 @@ class FindReplaceDialog extends Dialog {
if (findHistory != null) {
List<String> history= getFindHistory();
history.clear();
- for (int i= 0; i < findHistory.length; i++)
- history.add(findHistory[i]);
+ Collections.addAll(history, findHistory);
}
String[] replaceHistory= s.getArray("replacehistory"); //$NON-NLS-1$
if (replaceHistory != null) {
List<String> history= getReplaceHistory();
history.clear();
- for (int i= 0; i < replaceHistory.length; i++)
- history.add(replaceHistory[i]);
+ Collections.addAll(history, replaceHistory);
}
}

Back to the top