Bug 88653 [Commands] performance: 50% of perspective switch in ParameterizedCommand.equals()
Build: I20050315 Setup: 1) Workspace with three projects, org.eclipse.jdt.core, org.eclipse.swt, and org.eclipse.swt.win32 2) Editor open on org.eclipse.jdt.internal.compiler.parser.Parser.java 3) Default Java perspective and Resource perspective open My test was to switch between the two open perspectives about five times using Ctrl+F8. The profiler showed 50% of the time in ParameterizedCommand.equals() and in the methods called by that equals implementation (Util.equals() and Command.equals()). The main problem is probably in the number of times this method is called (about 1.6 million times). This seems to be caused by a large number of property change events: ExternalActionManager$CommandCallback.bindingManagerChanged is called 30 times. This in turn calls ActionContributionItem$1.propertyChange, which is called 4787 times. The number of method calls explodes as you go down the call stack, until the equals method that is called 1.6 million times. I will attach profiler output to show more details. If the number of change events can't be reduced, it looks like the implementation of ParameterizedCommand.equals() can be made faster by first comparing the cached hash code. Only if the hash codes are the same does it need to do the remainder of the equality testing.
bundles/org.eclipse.core.commands/src/org/eclipse/core/commands/ParameterizedCommand.java
private final Command command;
	/**
	 * The hash code for this object. This value is computed lazily, and marked
	 * as invalid when one of the values on which it is based changes.
	 */
	private transient int hashCode = HASH_CODE_NOT_COMPUTED;
	/**
	 * This is an array of parameterization defined for this command. This value
	 * may be <code>null</code> if the command has no parameters.
	 */
	private final Parameterization[] parameterizations;
	/**
	 * Constructs a new instance of <code>ParameterizedCommand</code> with
	 * specific values for zero or more of its parameters.
	 * 
	 * @param command
	 *            The command that is parameterized; must not be
	 *            <code>null</code>.
	 * @param parameterizations
	 *            The parameterization of the command. This value may be
	 *            <code>null</code>. If it is not <code>null</code> then it
	 *            should be an array of quadruples (<code>String[]</code>).
	 *            These quadruples are indexed using the <code>INDEX</code>
	 *            constants defined in this class. This argument is not copied;
	 *            if you need to make changes to it after constructing this
	 *            parameterized command, then make a copy yourself.
	 */
	public ParameterizedCommand(final Command command,
			final Parameterization[] parameterizations) {
		if (command == null) {