Skip to content

Commit

Permalink
Cherry-pick ad21476. rdar://problem/105010273
Browse files Browse the repository at this point in the history
    EventListenerMap's m_entries vector wastes a lot of vector capacity
    https://bugs.webkit.org/show_bug.cgi?id=251697
    <rdar://problem/105010273>

    Reviewed by Mark Lam.

    EventListenerMap's vector wastes capacity, since it allocates 16 slots but uses on average 1.63 of them; most contain only 1.
    So set the initial capacity to 4. This saves about 54K on nytimes.com. It measures as perf neutral on Speedometer.

    * Source/WebCore/dom/EventListenerMap.h:

    Canonical link: https://commits.webkit.org/259920@main

Canonical link: https://commits.webkit.org/259548.226@safari-7615-branch
  • Loading branch information
smfr authored and MyahCobbs committed Feb 21, 2023
1 parent a84aa49 commit 120a006
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Source/WebCore/dom/EventListenerMap.h
Expand Up @@ -74,7 +74,7 @@ class EventListenerMap {
Lock& lock() { return m_lock; }

private:
Vector<std::pair<AtomString, EventListenerVector>> m_entries;
Vector<std::pair<AtomString, EventListenerVector>, 0, CrashOnOverflow, 4> m_entries;
Lock m_lock;
};

Expand Down

0 comments on commit 120a006

Please sign in to comment.