Project: Eclipse_Platform_UI
Bug 259553 [TabbedProperties] expensive refresh of text
Reported: 2008-12-23 06:01:25 | Status: verified fixed

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).

Files changed in fix:
bundles/org.eclipse.ui.views.properties.tabbed/src/org/eclipse/ui/internal/views/properties/tabbed/view/TabbedPropertyList.java