Bug 1225873 - micro-optimize creating event target chains; r=smaug

This code is only called in a few cases that aren't on the critical
path, but less code is less code: we eliminate the checks for whether we
have enough space in the copying loop, and maybe save some function
calls.
This commit is contained in:
Nathan Froyd 2015-11-18 09:48:45 -05:00
parent 53349d20c9
commit 23ca44b6a7

View File

@ -642,9 +642,10 @@ EventDispatcher::Dispatch(nsISupports* aTarget,
if (NS_SUCCEEDED(rv)) {
if (aTargets) {
aTargets->Clear();
aTargets->SetCapacity(chain.Length());
for (uint32_t i = 0; i < chain.Length(); ++i) {
aTargets->AppendElement(chain[i].CurrentTarget()->GetTargetForDOMEvent());
uint32_t numTargets = chain.Length();
EventTarget** targets = aTargets->AppendElements(numTargets);
for (uint32_t i = 0; i < numTargets; ++i) {
targets[i] = chain[i].CurrentTarget()->GetTargetForDOMEvent();
}
} else {
// Event target chain is created. Handle the chain.