Changeset 102882 in webkit


Ignore:
Timestamp:
Dec 14, 2011 9:26:55 PM (12 years ago)
Author:
adamk@chromium.org
Message:

Optimize MutationObserverInterestGroup construction
https://bugs.webkit.org/show_bug.cgi?id=74563

Reviewed by Ojan Vafai.

Inline MutationObserverInterestGroup's creation methods and fix an
accidental pass-by-value in an attempt to further reduce the CPU
footprint of MutationObservers.

No new tests, refactor only.

  • dom/WebKitMutationObserver.cpp:

(WebCore::MutationObserverInterestGroup::MutationObserverInterestGroup): Pass observers HashMap by reference.

  • dom/WebKitMutationObserver.h:

(WebCore::MutationObserverInterestGroup::createForChildListMutation): Inline.
(WebCore::MutationObserverInterestGroup::createForCharacterDataMutation): Inline.
(WebCore::MutationObserverInterestGroup::createForAttributesMutation): Inline.
(WebCore::MutationObserverInterestGroup::hasOldValue): Remove spurious inline keyword.

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r102877 r102882  
     12011-12-14  Adam Klein  <adamk@chromium.org>
     2
     3        Optimize MutationObserverInterestGroup construction
     4        https://bugs.webkit.org/show_bug.cgi?id=74563
     5
     6        Reviewed by Ojan Vafai.
     7
     8        Inline MutationObserverInterestGroup's creation methods and fix an
     9        accidental pass-by-value in an attempt to further reduce the CPU
     10        footprint of MutationObservers.
     11
     12        No new tests, refactor only.
     13
     14        * dom/WebKitMutationObserver.cpp:
     15        (WebCore::MutationObserverInterestGroup::MutationObserverInterestGroup): Pass observers HashMap by reference.
     16        * dom/WebKitMutationObserver.h:
     17        (WebCore::MutationObserverInterestGroup::createForChildListMutation): Inline.
     18        (WebCore::MutationObserverInterestGroup::createForCharacterDataMutation): Inline.
     19        (WebCore::MutationObserverInterestGroup::createForAttributesMutation): Inline.
     20        (WebCore::MutationObserverInterestGroup::hasOldValue): Remove spurious inline keyword.
     21
    1222011-12-14  Dominic Mazzoni  <dmazzoni@google.com>
    223
  • trunk/Source/WebCore/dom/WebKitMutationObserver.cpp

    r102721 r102882  
    163163}
    164164
    165 PassOwnPtr<MutationObserverInterestGroup> MutationObserverInterestGroup::createForChildListMutation(Node* target)
    166 {
    167     MutationRecordDeliveryOptions oldValueFlag = 0;
    168     return createIfNeeded(target, WebKitMutationObserver::ChildList, nullAtom, oldValueFlag);
    169 }
    170 
    171 PassOwnPtr<MutationObserverInterestGroup> MutationObserverInterestGroup::createForCharacterDataMutation(Node* target)
    172 {
    173     return createIfNeeded(target, WebKitMutationObserver::CharacterData, nullAtom, WebKitMutationObserver::CharacterDataOldValue);
    174 }
    175 
    176 PassOwnPtr<MutationObserverInterestGroup> MutationObserverInterestGroup::createForAttributesMutation(Node* target, const QualifiedName& attributeName)
    177 {
    178     return createIfNeeded(target, WebKitMutationObserver::Attributes, attributeName.localName(), WebKitMutationObserver::AttributeOldValue);
    179 }
    180 
    181 MutationObserverInterestGroup::MutationObserverInterestGroup(HashMap<WebKitMutationObserver*, MutationRecordDeliveryOptions> observers, MutationRecordDeliveryOptions oldValueFlag)
     165MutationObserverInterestGroup::MutationObserverInterestGroup(HashMap<WebKitMutationObserver*, MutationRecordDeliveryOptions>& observers, MutationRecordDeliveryOptions oldValueFlag)
    182166    : m_oldValueFlag(oldValueFlag)
    183167{
  • trunk/Source/WebCore/dom/WebKitMutationObserver.h

    r102721 r102882  
    3434#if ENABLE(MUTATION_OBSERVERS)
    3535
     36#include "QualifiedName.h"
    3637#include <wtf/HashMap.h>
    3738#include <wtf/HashSet.h>
     39#include <wtf/PassOwnPtr.h>
    3840#include <wtf/PassRefPtr.h>
    3941#include <wtf/RefCounted.h>
     
    99101class MutationObserverInterestGroup {
    100102public:
    101     static PassOwnPtr<MutationObserverInterestGroup> createForChildListMutation(Node* target);
    102     static PassOwnPtr<MutationObserverInterestGroup> createForCharacterDataMutation(Node* target);
    103     static PassOwnPtr<MutationObserverInterestGroup> createForAttributesMutation(Node* target, const QualifiedName& attributeName);
     103    static PassOwnPtr<MutationObserverInterestGroup> createForChildListMutation(Node* target)
     104    {
     105        MutationRecordDeliveryOptions oldValueFlag = 0;
     106        return createIfNeeded(target, WebKitMutationObserver::ChildList, nullAtom, oldValueFlag);
     107    }
     108    static PassOwnPtr<MutationObserverInterestGroup> createForCharacterDataMutation(Node* target)
     109    {
     110        return createIfNeeded(target, WebKitMutationObserver::CharacterData, nullAtom, WebKitMutationObserver::CharacterDataOldValue);
     111    }
     112    static PassOwnPtr<MutationObserverInterestGroup> createForAttributesMutation(Node* target, const QualifiedName& attributeName)
     113    {
     114        return createIfNeeded(target, WebKitMutationObserver::Attributes, attributeName.localName(), WebKitMutationObserver::AttributeOldValue);
     115    }
    104116
    105117    bool isOldValueRequested();
    106118    void enqueueMutationRecord(PassRefPtr<MutationRecord>);
     119
    107120private:
    108121    static PassOwnPtr<MutationObserverInterestGroup> createIfNeeded(Node* target, WebKitMutationObserver::MutationType, const AtomicString& attributeName, MutationRecordDeliveryOptions oldValueFlag);
    109     MutationObserverInterestGroup(HashMap<WebKitMutationObserver*, MutationRecordDeliveryOptions> observers, MutationRecordDeliveryOptions oldValueFlag);
     122    MutationObserverInterestGroup(HashMap<WebKitMutationObserver*, MutationRecordDeliveryOptions>& observers, MutationRecordDeliveryOptions oldValueFlag);
    110123
    111     inline bool hasOldValue(MutationRecordDeliveryOptions options) { return options & m_oldValueFlag; }
     124    bool hasOldValue(MutationRecordDeliveryOptions options) { return options & m_oldValueFlag; }
    112125
    113126    HashMap<WebKitMutationObserver*, MutationRecordDeliveryOptions> m_observers;
Note: See TracChangeset for help on using the changeset viewer.