eventSource currently uses a plain object to store the mapping of events to listeners, and the listener groups are arrays. eventSource.removeListener works by filtering the array of listeners and creating an entirely new array, so is inefficient (eventSource.addOneTimeListener uses this). As the event handler methods tend to be hot code, I think it would worth optimizing by switching to Sets for the listeners instead of arrays. A more minor optimization would be to switch the events object to use a Map.
Created attachment 725127 [details] [diff] [review] initial attempt at converting to use Map and Set
Since we're planning to migrate to using Addon SDK's EventEmitter, this is unneeded.