Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Wolf2016-09-02 21:52:40 +0000
committerMatthias Sohn2016-09-08 21:34:32 +0000
commit007bae457098407bcfc762c64b23f8b690a197c4 (patch)
tree283f4170b0a1c6fdb3ec0b0bf1668ee74c328410
parent8d005606f73508917fb23b5ade4144304ac39442 (diff)
downloadegit-007bae457098407bcfc762c64b23f8b690a197c4.tar.gz
egit-007bae457098407bcfc762c64b23f8b690a197c4.tar.xz
egit-007bae457098407bcfc762c64b23f8b690a197c4.zip
Speed up context menu in staging view
The context menu in the staging view could take _very_ long to appear on a folder node with many children. This was caused by (a) the quadratic algorithm using lists, and (b) by the frequent re-allocations occurring in one of those lists. Fix by collecting the staging entries in a linked hash set, which offers faster membership testing and (for this use case) better memory management. Only convert to a list (as required by the structured selection used) once all staging entries have been collected. The context menu now appears quickly, even on large folders. However, applying actions may now still take very long. For instance, selecting "Ignore" on a (non-expanded) folder containing 50000 files tries to add all those 50000 files one after the other to a .gitignore, which takes ages. This is not fixed by this change; there is a long-standing TODO for this in IgnoreOperation. Bug: 500106 Change-Id: I03979d525618fbcf23c6d73c9f4ec3dbf4637d10 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java19
1 files changed, 9 insertions, 10 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java
index 999e6db6ad..f530dfd1d8 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java
@@ -2483,7 +2483,7 @@ public class StagingView extends ViewPart implements IShowInSource {
if (selection.isEmpty())
return;
- List<StagingEntry> stagingEntryList = new ArrayList<>();
+ Set<StagingEntry> stagingEntrySet = new LinkedHashSet<>();
boolean submoduleSelected = false;
boolean folderSelected = false;
@@ -2492,23 +2492,22 @@ public class StagingView extends ViewPart implements IShowInSource {
StagingFolderEntry folder = (StagingFolderEntry) element;
folderSelected = true;
StagingViewContentProvider contentProvider = getContentProvider(treeViewer);
- List<StagingEntry> stagingEntries = contentProvider
- .getStagingEntriesFiltered(folder);
- for (StagingEntry stagingEntry : stagingEntries) {
- if (!stagingEntryList.contains(stagingEntry))
- stagingEntryList.add(stagingEntry);
- }
+ stagingEntrySet.addAll(contentProvider
+ .getStagingEntriesFiltered(folder));
} else if (element instanceof StagingEntry) {
StagingEntry entry = (StagingEntry) element;
- if (entry.isSubmodule())
+ if (entry.isSubmodule()) {
submoduleSelected = true;
- if (!stagingEntryList.contains(entry))
- stagingEntryList.add(entry);
+ }
+ stagingEntrySet.add(entry);
}
}
+ List<StagingEntry> stagingEntryList = new ArrayList<>(
+ stagingEntrySet);
final IStructuredSelection fileSelection = new StructuredSelection(
stagingEntryList);
+ stagingEntrySet = null;
if (!folderSelected) {
Action openWorkingTreeVersion = new Action(

Back to the top