Changeset 61495 in webkit


Ignore:
Timestamp:
Jun 19, 2010 10:11:35 AM (14 years ago)
Author:
eric@webkit.org
Message:

2010-06-19 Jay Civelli <jcivelli@chromium.org>

Reviewed by David Levin.

Adding a < operator to WebURLs so they can be used in std::maps.
https://bugs.webkit.org/show_bug.cgi?id=40632

  • public/WebCString.h: (WebKit::operator<):
  • public/WebURL.h: (WebKit::operator<):
  • src/WebCString.cpp: (WebKit::WebCString::compare):
Location:
trunk/WebKit/chromium
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit/chromium/ChangeLog

    r61490 r61495  
     12010-06-19  Jay Civelli  <jcivelli@chromium.org>
     2
     3        Reviewed by David Levin.
     4
     5        Adding a < operator to WebURLs so they can be used in std::maps.
     6        https://bugs.webkit.org/show_bug.cgi?id=40632
     7
     8        * public/WebCString.h:
     9        (WebKit::operator<):
     10        * public/WebURL.h:
     11        (WebKit::operator<):
     12        * src/WebCString.cpp:
     13        (WebKit::WebCString::compare):
     14
    1152010-06-19  Kent Tamura  <tkent@chromium.org>
    216
  • trunk/WebKit/chromium/public/WebCString.h

    r56825 r61495  
    6969    }
    7070
     71    // Returns 0 if both strings are equals, a value greater than zero if the
     72    // first character that does not match has a greater value in this string
     73    // than in |other|, or a value less than zero to indicate the opposite.
     74    WEBKIT_API int compare(const WebCString& other) const;
     75
    7176    WEBKIT_API void reset();
    7277    WEBKIT_API void assign(const WebCString&);
     
    118123};
    119124
     125inline bool operator<(const WebCString& a, const WebCString& b)
     126{
     127    return a.compare(b) < 0;
     128}
     129
    120130} // namespace WebKit
    121131
  • trunk/WebKit/chromium/public/WebURL.h

    r50682 r61495  
    139139};
    140140
     141inline bool operator<(const WebURL& a, const WebURL& b)
     142{
     143    return a.spec() < b.spec();
     144}
     145
    141146} // namespace WebKit
    142147
  • trunk/WebKit/chromium/src/WebCString.cpp

    r56825 r61495  
    4141class WebCStringPrivate : public WTF::CStringBuffer {
    4242};
     43
     44int WebCString::compare(const WebCString& other) const
     45{
     46    // A null string is always less than a non null one.
     47    if (isNull() != other.isNull())
     48        return isNull() ? -1 : 1;
     49
     50    if (isNull())
     51        return 0; // Both WebStrings are null.
     52
     53    return strcmp(m_private->data(), other.m_private->data());
     54}
    4355
    4456void WebCString::reset()
Note: See TracChangeset for help on using the changeset viewer.