Bug 259553 [TabbedProperties] expensive refresh of text
I have absolutely no idea as to which component I should raise this bug against, took the general "platform ui" instead. We have an (GMF-based) application making heavy use of the tabbed properties view in order to display something more appealing than the classical table for our elements. All goes well except ... it can become really expensive to refresh (when the user selects a new element or when anything changes in the diagram) when text is shown. A profiler (Yourkit) shows that most (20%!) of the update time is spent in org.eclipse.ui.internal.views.properties.tabbed.view.TabbedPropertyList.getTextDimension(String) . private Point getTextDimension(String text) { Shell shell = new Shell(); GC gc = new GC(shell); gc.setFont(JFaceResources.getFontRegistry().getBold( JFaceResources.DEFAULT_FONT)); Point point = gc.textExtent(text); point.x++; gc.dispose(); shell.dispose(); return point; } Why? Because of the very first line of this method : the SWT Shell is really time consumng to instantiate ... especially when it is done so many times. Since this Shell's one and only purpose is to instantiate a GC, why didn't you use something like "new GC(Display.getDefault())" or if you really want to use a Shell, "new GC(Display.getDefault().getActiveShell())" ? That would save us all the initialisation time for a rough 18% performance gain (as measured on our application).
bundles/org.eclipse.ui.views.properties.tabbed/src/org/eclipse/ui/internal/views/properties/tabbed/view/TabbedPropertyList.java
String properties_not_available = TabbedPropertyMessages.TabbedPropertyList_properties_not_available;
			result.x = getTextDimension(properties_not_available).x + INDENT;
		} else {
			ITabItem widestTab = elements[widestLabelIndex].getTabItem();
			int width = getTextDimension(widestTab.getText()).x + INDENT;
			/*
			 * To anticipate for the icon placement we should always keep the
			 * space available after the label. So when the active tab includes
			 * an icon the width of the tab doesn't change.
			 */
			if (widestTab.getImage() != null) {
				width = width + 16 + 4;
			}
			if (widestTab.isIndented()) {
				width = width + 10;
			}
			/*
			 * Add 10 pixels to the right of the longest string as a margin.
			 */
			result.x = width + 10;
		}
		return result;
	}
	/**
	 * Get the dimensions of the provided string.
	 * 
	 * @param text
	 *            the string.
	 * @return the dimensions of the provided string.
	 */