Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Wolf2016-09-02 21:23:53 +0000
committerThomas Wolf2016-09-07 06:55:40 +0000
commitc874cca93dcd42ab675469b20774595a5b75ace7 (patch)
tree07354196b7e7143e95cdda3834e02db3d2ef46da
parent2ba61eaa90f9a112a232698bdc3d5b3720cbce91 (diff)
downloadegit-c874cca93dcd42ab675469b20774595a5b75ace7.tar.gz
egit-c874cca93dcd42ab675469b20774595a5b75ace7.tar.xz
egit-c874cca93dcd42ab675469b20774595a5b75ace7.zip
More efficient label provider for the staging view
The staging view's label provider was derived from DecoratingLabelProvider, which is an ITreePathLabelProvider. For these, the TreeViewer's WrappedViewerLabelProvider computes the tree path for each element, which then ultimately isn't used because the StagingViewLabelProvider is _not_ an ITreePathLabelProvider. This tree path computation is, at least on GTK, fairly expensive. By not deriving our label provider from DecoratingLabelProvider but wrapping it, we can ensure that the framework does not compute these tree paths that are then not used anyway, and decorations are significantly faster on GTK. Bug: 500106 Change-Id: If30bfbfeda6df2f89022995e8ba375be8c45ca3e Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java58
1 files changed, 43 insertions, 15 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 8a0ee7456..999e6db6a 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
@@ -118,6 +118,7 @@ import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.LocalSelectionTransfer;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.AbstractTreeViewer;
+import org.eclipse.jface.viewers.BaseLabelProvider;
import org.eclipse.jface.viewers.ContentViewer;
import org.eclipse.jface.viewers.DecoratingLabelProvider;
import org.eclipse.jface.viewers.IBaseLabelProvider;
@@ -469,33 +470,60 @@ public class StagingView extends ViewPart implements IShowInSource {
}
}
- static class TreeDecoratingLabelProvider extends DecoratingLabelProvider {
-
- ILabelProvider provider;
+ /**
+ * A wrapped {@link DecoratingLabelProvider} to be used in the tree viewers
+ * of the staging view. We wrap it instead of deriving directly because a
+ * {@link DecoratingLabelProvider} is a
+ * {@link org.eclipse.jface.viewers.ITreePathLabelProvider
+ * ITreePathLabelProvider}, which makes the tree viewer compute a
+ * {@link org.eclipse.jface.viewers.TreePath TreePath} for each element,
+ * which is then ultimately unused because the
+ * {@link StagingViewLabelProvider} is <em>not</em> a
+ * {@link org.eclipse.jface.viewers.ITreePathLabelProvider
+ * ITreePathLabelProvider}. Computing the
+ * {@link org.eclipse.jface.viewers.TreePath TreePath} is a fairly expensive
+ * operation on GTK, and avoiding to compute it speeds up label updates
+ * significantly.
+ */
+ private static class TreeDecoratingLabelProvider extends BaseLabelProvider
+ implements ILabelProvider {
- ILabelDecorator decorator;
+ private final DecoratingLabelProvider provider;
public TreeDecoratingLabelProvider(ILabelProvider provider,
ILabelDecorator decorator) {
- super(provider, decorator);
- this.provider = provider;
- this.decorator = decorator;
+ this.provider = new DecoratingLabelProvider(provider, decorator);
}
- public Image getColumnImage(Object element) {
- Image image = provider.getImage(element);
- if (image != null && decorator != null) {
- Image decorated = decorator.decorateImage(image, element);
- if (decorated != null)
- return decorated;
- }
- return image;
+ @Override
+ public Image getImage(Object element) {
+ return provider.getImage(element);
}
@Override
public String getText(Object element) {
return provider.getText(element);
}
+
+ @Override
+ public void addListener(ILabelProviderListener listener) {
+ provider.addListener(listener);
+ }
+
+ @Override
+ public void removeListener(ILabelProviderListener listener) {
+ provider.removeListener(listener);
+ }
+
+ @Override
+ public void dispose() {
+ provider.dispose();
+ }
+
+ public ILabelProvider getLabelProvider() {
+ return provider.getLabelProvider();
+ }
+
}
static class StagingViewSearchThread extends Thread {

Back to the top