Changeset 156307 in webkit


Ignore:
Timestamp:
Sep 23, 2013 4:53:28 PM (11 years ago)
Author:
andersca@apple.com
Message:

Test the waters and begin using lambdas
https://bugs.webkit.org/show_bug.cgi?id=121809

Reviewed by Andreas Kling.

Source/WebCore:

Use lambdas instead of static functions and function objects.

  • css/MediaQuery.cpp:

(WebCore::MediaQuery::MediaQuery):

  • dom/MutationObserver.cpp:

(WebCore::MutationObserver::deliverAllMutations):

  • page/CaptionUserPreferences.cpp:

(WebCore::CaptionUserPreferences::sortedTrackListForMenu):

Source/WTF:

  • wtf/ListDump.h:

(WTF::sortedListDump):
Use std::less instead of a custom lessThan function.

Location:
trunk/Source
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r156305 r156307  
     12013-09-23  Anders Carlsson  <andersca@apple.com>
     2
     3        Test the waters and begin using lambdas
     4        https://bugs.webkit.org/show_bug.cgi?id=121809
     5
     6        Reviewed by Andreas Kling.
     7
     8        * wtf/ListDump.h:
     9        (WTF::sortedListDump):
     10        Use std::less instead of a custom lessThan function.
     11
    1122013-09-23  Anders Carlsson  <andersca@apple.com>
    213
  • trunk/Source/WTF/wtf/ListDump.h

    r153294 r156307  
    9595
    9696template<typename T>
    97 inline bool lessThan(const T& a, const T& b)
    98 {
    99     return a < b;
    100 }
    101 
    102 template<typename T>
    10397CString sortedListDump(const T& list, const char* comma = ", ")
    10498{
    105     return sortedListDump(list, lessThan<typename T::ValueType>, comma);
     99    return sortedListDump(list, std::less<typename T::ValueType>(), comma);
    106100}
    107101
  • trunk/Source/WebCore/ChangeLog

    r156306 r156307  
     12013-09-23  Anders Carlsson  <andersca@apple.com>
     2
     3        Test the waters and begin using lambdas
     4        https://bugs.webkit.org/show_bug.cgi?id=121809
     5
     6        Reviewed by Andreas Kling.
     7
     8        Use lambdas instead of static functions and function objects.
     9       
     10        * css/MediaQuery.cpp:
     11        (WebCore::MediaQuery::MediaQuery):
     12        * dom/MutationObserver.cpp:
     13        (WebCore::MutationObserver::deliverAllMutations):
     14        * page/CaptionUserPreferences.cpp:
     15        (WebCore::CaptionUserPreferences::sortedTrackListForMenu):
     16
    1172013-09-23  Patrick Gansterer  <paroga@webkit.org>
    218
  • trunk/Source/WebCore/css/MediaQuery.cpp

    r155277 r156307  
    7373}
    7474
    75 static bool expressionCompare(const OwnPtr<MediaQueryExp>& a, const OwnPtr<MediaQueryExp>& b)
    76 {
    77     return codePointCompare(a->serialize(), b->serialize()) < 0;
    78 }
    79 
    8075MediaQuery::MediaQuery(Restrictor r, const String& mediaType, PassOwnPtr<ExpressionVector> exprs)
    8176    : m_restrictor(r)
     
    8984    }
    9085
    91     std::sort(m_expressions->begin(), m_expressions->end(), expressionCompare);
     86    std::sort(m_expressions->begin(), m_expressions->end(), [](const OwnPtr<MediaQueryExp>& a, const OwnPtr<MediaQueryExp>& b) {
     87        return codePointCompare(a->serialize(), b->serialize()) < 0;
     88    });
    9289
    9390    // remove all duplicated expressions
  • trunk/Source/WebCore/dom/MutationObserver.cpp

    r153447 r156307  
    4949static unsigned s_observerPriority = 0;
    5050
    51 struct MutationObserver::ObserverLessThan {
    52     bool operator()(const RefPtr<MutationObserver>& lhs, const RefPtr<MutationObserver>& rhs)
    53     {
    54         return lhs->m_priority < rhs->m_priority;
    55     }
    56 };
    57 
    5851PassRefPtr<MutationObserver> MutationObserver::create(PassRefPtr<MutationCallback> callback)
    5952{
     
    232225        copyToVector(activeMutationObservers(), observers);
    233226        activeMutationObservers().clear();
    234         std::sort(observers.begin(), observers.end(), ObserverLessThan());
     227        std::sort(observers.begin(), observers.end(), [](const RefPtr<MutationObserver>& lhs, const RefPtr<MutationObserver>& rhs) {
     228            return lhs->m_priority < rhs->m_priority;
     229        });
     230
    235231        for (size_t i = 0; i < observers.size(); ++i) {
    236232            if (observers[i]->canDeliver())
  • trunk/Source/WebCore/page/CaptionUserPreferences.cpp

    r155277 r156307  
    174174}
    175175   
    176 static bool textTrackCompare(const RefPtr<TextTrack>& a, const RefPtr<TextTrack>& b)
    177 {
    178     return codePointCompare(trackDisplayName(a.get()), trackDisplayName(b.get())) < 0;
    179 }
    180 
    181176Vector<RefPtr<TextTrack>> CaptionUserPreferences::sortedTrackListForMenu(TextTrackList* trackList)
    182177{
     
    188183        tracksForMenu.append(trackList->item(i));
    189184
    190     std::sort(tracksForMenu.begin(), tracksForMenu.end(), textTrackCompare);
     185    std::sort(tracksForMenu.begin(), tracksForMenu.end(), [](const RefPtr<TextTrack>& a, const RefPtr<TextTrack>& b) {
     186        return codePointCompare(trackDisplayName(a.get()), trackDisplayName(b.get())) < 0;
     187    });
    191188
    192189    tracksForMenu.insert(0, TextTrack::captionMenuOffItem());
Note: See TracChangeset for help on using the changeset viewer.