Project: Eclipse_Platform_UI
Bug 74230 [Workbench] Introduce new UIStats.shouldDebug(int operation)
Reported: 2004-09-18 11:08:58 | Status: verified fixed

public static void shouldDebug(int operation) { return debug[operation]; } @@@@ Reasoning: Creation of debug strings in the WorkbenchWindow#fire* methods waste CPU cycles and create lots of unnecessary String objects. It should only be done if the corresponding debug mode is on. @@@@ Exampe usage: /** * Fires perspective changed */ void firePerspectiveChanged(IWorkbenchPage page, IPerspectiveDescriptor perspective, String changeId) { String label = null; if (UIStats.shouldDebug(UIStats.NOTIFY_PERSPECTIVE_LISTENERS)) label = "changed perspective = " + perspective.getId() + ", page = " + page.getLabel() //$NON-NLS-1$ //$NON-NLS-2$ + ", changeId = " + changeId; //$NON-NLS-1$ try { UIStats.start(UIStats.NOTIFY_PERSPECTIVE_LISTENERS, label); perspectiveListeners .firePerspectiveChanged(page, perspective, changeId); perspectiveService.firePerspectiveChanged(page, perspective, changeId); } finally { UIStats.end(UIStats.NOTIFY_PERSPECTIVE_LISTENERS, label); } }

Files changed in fix:
bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/EditorManager.java bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ViewFactory.java bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchWindow.java