Bug 136763 Performance improvements to BindingManager
Build id: I20060413-0010 One of our performance tests that still shows significant regression is opening editors. With profiling I found that 0.8% of that time is in Collections.unmodifiableMap(...) called by three methods in BindingManager. Another 0.15% is from instantiating new TrigerSequence[0] in three locations in BindingManager. In the first case, the creation of an immutable map is completely unnecessary - the methods are private, the maps are never exposed across API boundaries, and there is never any risk that the maps will be modified. The creation of empty TriggerSequence arrays can also be avoided with a singleton. I will attach a patch that collectively saves about 1% of the total editor startup time (elapsed time as measured by sampling profiler). These are very simple and safe fixes that I recommend considering for RC2.
bundles/org.eclipse.jface/src/org/eclipse/jface/bindings/BindingManager.java
return (TriggerSequence[]) collection
					.toArray(new TriggerSequence[collection.size()]);
		}
		return new TriggerSequence[0];
	}
	/**
	 * A variation on {@link BindingManager#getActiveBindingsFor(String)} that
	 * returns an array of bindings, rather than trigger sequences. This method
	 * is needed for doing "best" calculationgs on the active bindings.
	 * 
	 * @param commandId
	 *            The identifier of the command for which the active bindings
	 *            should be retrieved; must not be <code>null</code>.
	 * @return The active bindings for the given command; this value may be
	 *         <code>null</code> if there are no active bindings.
	 * @since 3.2
	 */
	private final Binding[] getActiveBindingsFor1(final String commandId) {
		final TriggerSequence[] triggers = getActiveBindingsFor(commandId);
		if (triggers.length == 0) {
			return null;
		}
		final Map activeBindings = getActiveBindings();
		if (activeBindings != null) {
			final Binding[] bindings = new Binding[triggers.length];
			for (int i = 0; i < triggers.length; i++) {
				final TriggerSequence triggerSequence = triggers[i];
				final Object object = activeBindings.get(triggerSequence);
				final Binding binding = (Binding) object;
				bindings[i] = binding;