Title: [115669] trunk/Source
Revision
115669
Author
[email protected]
Date
2012-04-30 14:32:44 -0700 (Mon, 30 Apr 2012)

Log Message

Add String::startsWith() and endsWith() for string literals
https://bugs.webkit.org/show_bug.cgi?id=85154

Reviewed by Darin Adler.

Source/WebCore: 

Update WebCore to use the simpler startsWith() and endsWith() taking
a UChar.

* css/CSSParser.cpp:
(WebCore::CSSParser::markPropertyEnd):
* css/WebKitCSSKeyframeRule.cpp:
(WebCore::StyleKeyframe::parseKeyString):
* editing/markup.cpp:
(WebCore::createFragmentFromText):
* html/HTMLObjectElement.cpp:
(WebCore::HTMLObjectElement::addSubresourceAttributeURLs):
* html/HTMLTextFormControlElement.cpp:
(WebCore::HTMLTextFormControlElement::setInnerTextValue):
* inspector/ContentSearchUtils.cpp:
(WebCore::ContentSearchUtils::getRegularExpressionMatchesByLines):
* inspector/InspectorCSSAgent.cpp:
(WebCore::InspectorCSSAgent::SetPropertyTextAction::redo):
* loader/MainResourceLoader.cpp:
(WebCore::MainResourceLoader::substituteMIMETypeFromPluginDatabase):
* loader/appcache/ManifestParser.cpp:
(WebCore::parseManifest):
* platform/blackberry/CookieManager.cpp:
(WebCore::CookieManager::shouldRejectForSecurityReason):
* platform/posix/FileSystemPOSIX.cpp:
(WebCore::pathByAppendingComponent):
* plugins/PluginDatabase.cpp:
(WebCore::PluginDatabase::findPlugin):
* svg/SVGStopElement.cpp:
(WebCore::SVGStopElement::parseAttribute):
* svg/animation/SVGSMILElement.cpp:
(WebCore::SVGSMILElement::parseOffsetValue):
(WebCore::SVGSMILElement::parseCondition):

Source/WebKit/blackberry: 

* WebKitSupport/DOMSupport.cpp:
(BlackBerry::WebKit::DOMSupport::elementPatternMatches):

Source/WebKit2: 

Update WebKit2 to use String::endsWith(UChar).

* UIProcess/Plugins/PluginInfoStore.cpp:
(WebKit::pathExtension):

Source/WTF: 

When invoking StringImpl::startsWidth() or StringImpl::endsWith() with
a string literal, a new String was constructed implicitly, allocating
a new StringImpl and copying the characters for the operation.

This patch adds a version of those methods for single characters and
string literals.
This allows us to avoid allocating memory and use the characters in place,
and it permits some extra shortcuts in the implementation.

* wtf/text/AtomicString.h:
(WTF::AtomicString::startsWith):
(AtomicString):
(WTF::AtomicString::endsWith):
* wtf/text/StringImpl.cpp:
(WTF::equalInner):
(WTF):
(WTF::StringImpl::startsWith):
(WTF::StringImpl::endsWith):
* wtf/text/StringImpl.h:
(WTF::StringImpl::startsWith):
(StringImpl):
(WTF::StringImpl::endsWith):
* wtf/text/WTFString.h:
(WTF::String::startsWith):
(String):
(WTF::String::endsWith):

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (115668 => 115669)


--- trunk/Source/WTF/ChangeLog	2012-04-30 21:30:56 UTC (rev 115668)
+++ trunk/Source/WTF/ChangeLog	2012-04-30 21:32:44 UTC (rev 115669)
@@ -1,3 +1,37 @@
+2012-04-30  Benjamin Poulain  <[email protected]>
+
+        Add String::startsWith() and endsWith() for string literals
+        https://bugs.webkit.org/show_bug.cgi?id=85154
+
+        Reviewed by Darin Adler.
+
+        When invoking StringImpl::startsWidth() or StringImpl::endsWith() with
+        a string literal, a new String was constructed implicitly, allocating
+        a new StringImpl and copying the characters for the operation.
+
+        This patch adds a version of those methods for single characters and
+        string literals.
+        This allows us to avoid allocating memory and use the characters in place,
+        and it permits some extra shortcuts in the implementation.
+
+        * wtf/text/AtomicString.h:
+        (WTF::AtomicString::startsWith):
+        (AtomicString):
+        (WTF::AtomicString::endsWith):
+        * wtf/text/StringImpl.cpp:
+        (WTF::equalInner):
+        (WTF):
+        (WTF::StringImpl::startsWith):
+        (WTF::StringImpl::endsWith):
+        * wtf/text/StringImpl.h:
+        (WTF::StringImpl::startsWith):
+        (StringImpl):
+        (WTF::StringImpl::endsWith):
+        * wtf/text/WTFString.h:
+        (WTF::String::startsWith):
+        (String):
+        (WTF::String::endsWith):
+
 2012-04-30  Anders Carlsson  <[email protected]>
 
         WTF::bind should work with blocks

Modified: trunk/Source/WTF/wtf/text/AtomicString.h (115668 => 115669)


--- trunk/Source/WTF/wtf/text/AtomicString.h	2012-04-30 21:30:56 UTC (rev 115668)
+++ trunk/Source/WTF/wtf/text/AtomicString.h	2012-04-30 21:32:44 UTC (rev 115669)
@@ -81,8 +81,19 @@
     
     bool startsWith(const String& s, bool caseSensitive = true) const
         { return m_string.startsWith(s, caseSensitive); }
+    bool startsWith(UChar character) const
+        { return m_string.startsWith(character); }
+    template<unsigned matchLength>
+    bool startsWith(const char (&prefix)[matchLength], bool caseSensitive = true) const
+        { return m_string.startsWith<matchLength>(prefix, caseSensitive); }
+
     bool endsWith(const String& s, bool caseSensitive = true) const
         { return m_string.endsWith(s, caseSensitive); }
+    bool endsWith(UChar character) const
+        { return m_string.endsWith(character); }
+    template<unsigned matchLength>
+    bool endsWith(const char (&prefix)[matchLength], bool caseSensitive = true) const
+        { return m_string.endsWith<matchLength>(prefix, caseSensitive); }
     
     WTF_EXPORT_PRIVATE AtomicString lower() const;
     AtomicString upper() const { return AtomicString(impl()->upper()); }

Modified: trunk/Source/WTF/wtf/text/StringImpl.cpp (115668 => 115669)


--- trunk/Source/WTF/wtf/text/StringImpl.cpp	2012-04-30 21:30:56 UTC (rev 115668)
+++ trunk/Source/WTF/wtf/text/StringImpl.cpp	2012-04-30 21:32:44 UTC (rev 115669)
@@ -1095,6 +1095,35 @@
     return delta;
 }
 
+ALWAYS_INLINE static bool equalInner(const StringImpl* stringImpl, unsigned startOffset, const char* matchString, unsigned matchLength, bool caseSensitive)
+{
+    ASSERT(stringImpl);
+    ASSERT(matchLength <= stringImpl->length());
+    ASSERT(startOffset + matchLength <= stringImpl->length());
+
+    if (caseSensitive) {
+        if (stringImpl->is8Bit())
+            return equal(stringImpl->characters8() + startOffset, reinterpret_cast<const LChar*>(matchString), matchLength);
+        return equal(stringImpl->characters16() + startOffset, reinterpret_cast<const LChar*>(matchString), matchLength);
+    }
+    if (stringImpl->is8Bit())
+        return equalIgnoringCase(stringImpl->characters8() + startOffset, reinterpret_cast<const LChar*>(matchString), matchLength);
+    return equalIgnoringCase(stringImpl->characters16() + startOffset, reinterpret_cast<const LChar*>(matchString), matchLength);
+}
+
+bool StringImpl::startsWith(UChar character) const
+{
+    return m_length && (*this)[0] == character;
+}
+
+bool StringImpl::startsWith(const char* matchString, unsigned matchLength, bool caseSensitive) const
+{
+    ASSERT(matchLength);
+    if (matchLength > length())
+        return false;
+    return equalInner(this, 0, matchString, matchLength, caseSensitive);
+}
+
 bool StringImpl::endsWith(StringImpl* matchString, bool caseSensitive)
 {
     ASSERT(matchString);
@@ -1105,6 +1134,20 @@
     return false;
 }
 
+bool StringImpl::endsWith(UChar character) const
+{
+    return m_length && (*this)[m_length - 1] == character;
+}
+
+bool StringImpl::endsWith(const char* matchString, unsigned matchLength, bool caseSensitive) const
+{
+    ASSERT(matchLength);
+    if (matchLength > length())
+        return false;
+    unsigned startOffset = length() - matchLength;
+    return equalInner(this, startOffset, matchString, matchLength, caseSensitive);
+}
+
 PassRefPtr<StringImpl> StringImpl::replace(UChar oldC, UChar newC)
 {
     if (oldC == newC)

Modified: trunk/Source/WTF/wtf/text/StringImpl.h (115668 => 115669)


--- trunk/Source/WTF/wtf/text/StringImpl.h	2012-04-30 21:30:56 UTC (rev 115668)
+++ trunk/Source/WTF/wtf/text/StringImpl.h	2012-04-30 21:32:44 UTC (rev 115669)
@@ -498,7 +498,16 @@
     WTF_EXPORT_PRIVATE size_t reverseFindIgnoringCase(StringImpl*, unsigned index = UINT_MAX);
 
     bool startsWith(StringImpl* str, bool caseSensitive = true) { return (caseSensitive ? reverseFind(str, 0) : reverseFindIgnoringCase(str, 0)) == 0; }
+    WTF_EXPORT_PRIVATE bool startsWith(UChar) const;
+    WTF_EXPORT_PRIVATE bool startsWith(const char*, unsigned matchLength, bool caseSensitive) const;
+    template<unsigned matchLength>
+    bool startsWith(const char (&prefix)[matchLength], bool caseSensitive = true) const { return startsWith(prefix, matchLength - 1, caseSensitive); };
+
     WTF_EXPORT_PRIVATE bool endsWith(StringImpl*, bool caseSensitive = true);
+    WTF_EXPORT_PRIVATE bool endsWith(UChar) const;
+    WTF_EXPORT_PRIVATE bool endsWith(const char*, unsigned matchLength, bool caseSensitive) const;
+    template<unsigned matchLength>
+    bool endsWith(const char (&prefix)[matchLength], bool caseSensitive = true) const { return endsWith(prefix, matchLength - 1, caseSensitive); }
 
     WTF_EXPORT_PRIVATE PassRefPtr<StringImpl> replace(UChar, UChar);
     WTF_EXPORT_PRIVATE PassRefPtr<StringImpl> replace(UChar, StringImpl*);

Modified: trunk/Source/WTF/wtf/text/WTFString.h (115668 => 115669)


--- trunk/Source/WTF/wtf/text/WTFString.h	2012-04-30 21:30:56 UTC (rev 115668)
+++ trunk/Source/WTF/wtf/text/WTFString.h	2012-04-30 21:32:44 UTC (rev 115669)
@@ -248,8 +248,19 @@
 
     bool startsWith(const String& s, bool caseSensitive = true) const
         { return m_impl ? m_impl->startsWith(s.impl(), caseSensitive) : s.isEmpty(); }
+    bool startsWith(UChar character) const
+        { return m_impl ? m_impl->startsWith(character) : false; }
+    template<unsigned matchLength>
+    bool startsWith(const char (&prefix)[matchLength], bool caseSensitive = true) const
+        { return m_impl ? m_impl->startsWith<matchLength>(prefix, caseSensitive) : !matchLength; }
+
     bool endsWith(const String& s, bool caseSensitive = true) const
         { return m_impl ? m_impl->endsWith(s.impl(), caseSensitive) : s.isEmpty(); }
+    bool endsWith(UChar character) const
+        { return m_impl ? m_impl->endsWith(character) : false; }
+    template<unsigned matchLength>
+    bool endsWith(const char (&prefix)[matchLength], bool caseSensitive = true) const
+        { return m_impl ? m_impl->endsWith<matchLength>(prefix, caseSensitive) : !matchLength; }
 
     WTF_EXPORT_PRIVATE void append(const String&);
     WTF_EXPORT_PRIVATE void append(LChar);

Modified: trunk/Source/WebCore/ChangeLog (115668 => 115669)


--- trunk/Source/WebCore/ChangeLog	2012-04-30 21:30:56 UTC (rev 115668)
+++ trunk/Source/WebCore/ChangeLog	2012-04-30 21:32:44 UTC (rev 115669)
@@ -1,3 +1,43 @@
+2012-04-30  Benjamin Poulain  <[email protected]>
+
+        Add String::startsWith() and endsWith() for string literals
+        https://bugs.webkit.org/show_bug.cgi?id=85154
+
+        Reviewed by Darin Adler.
+
+        Update WebCore to use the simpler startsWith() and endsWith() taking
+        a UChar.
+
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::markPropertyEnd):
+        * css/WebKitCSSKeyframeRule.cpp:
+        (WebCore::StyleKeyframe::parseKeyString):
+        * editing/markup.cpp:
+        (WebCore::createFragmentFromText):
+        * html/HTMLObjectElement.cpp:
+        (WebCore::HTMLObjectElement::addSubresourceAttributeURLs):
+        * html/HTMLTextFormControlElement.cpp:
+        (WebCore::HTMLTextFormControlElement::setInnerTextValue):
+        * inspector/ContentSearchUtils.cpp:
+        (WebCore::ContentSearchUtils::getRegularExpressionMatchesByLines):
+        * inspector/InspectorCSSAgent.cpp:
+        (WebCore::InspectorCSSAgent::SetPropertyTextAction::redo):
+        * loader/MainResourceLoader.cpp:
+        (WebCore::MainResourceLoader::substituteMIMETypeFromPluginDatabase):
+        * loader/appcache/ManifestParser.cpp:
+        (WebCore::parseManifest):
+        * platform/blackberry/CookieManager.cpp:
+        (WebCore::CookieManager::shouldRejectForSecurityReason):
+        * platform/posix/FileSystemPOSIX.cpp:
+        (WebCore::pathByAppendingComponent):
+        * plugins/PluginDatabase.cpp:
+        (WebCore::PluginDatabase::findPlugin):
+        * svg/SVGStopElement.cpp:
+        (WebCore::SVGStopElement::parseAttribute):
+        * svg/animation/SVGSMILElement.cpp:
+        (WebCore::SVGSMILElement::parseOffsetValue):
+        (WebCore::SVGSMILElement::parseCondition):
+
 2012-04-30  Abhishek Arya  <[email protected]>
 
         Remove positioned float code.

Modified: trunk/Source/WebCore/css/CSSParser.cpp (115668 => 115669)


--- trunk/Source/WebCore/css/CSSParser.cpp	2012-04-30 21:30:56 UTC (rev 115668)
+++ trunk/Source/WebCore/css/CSSParser.cpp	2012-04-30 21:32:44 UTC (rev 115669)
@@ -9310,9 +9310,9 @@
         const unsigned end = m_propertyRange.end;
         ASSERT(start < end);
         String propertyString = String(m_dataStart.get() + start, end - start).stripWhiteSpace();
-        if (propertyString.endsWith(";", true))
+        if (propertyString.endsWith(';'))
             propertyString = propertyString.left(propertyString.length() - 1);
-        size_t colonIndex = propertyString.find(":");
+        size_t colonIndex = propertyString.find(':');
         ASSERT(colonIndex != notFound);
 
         String name = propertyString.left(colonIndex).stripWhiteSpace();

Modified: trunk/Source/WebCore/css/WebKitCSSKeyframeRule.cpp (115668 => 115669)


--- trunk/Source/WebCore/css/WebKitCSSKeyframeRule.cpp	2012-04-30 21:30:56 UTC (rev 115668)
+++ trunk/Source/WebCore/css/WebKitCSSKeyframeRule.cpp	2012-04-30 21:32:44 UTC (rev 115669)
@@ -53,7 +53,7 @@
             key = 0;
         else if (cur == "to")
             key = 1;
-        else if (cur.endsWith("%")) {
+        else if (cur.endsWith('%')) {
             float k = cur.substring(0, cur.length() - 1).toFloat();
             if (k >= 0 && k <= 100)
                 key = k/100;

Modified: trunk/Source/WebCore/editing/markup.cpp (115668 => 115669)


--- trunk/Source/WebCore/editing/markup.cpp	2012-04-30 21:30:56 UTC (rev 115668)
+++ trunk/Source/WebCore/editing/markup.cpp	2012-04-30 21:32:44 UTC (rev 115669)
@@ -859,7 +859,7 @@
     if (renderer && renderer->style()->preserveNewline()) {
         fragment->appendChild(document->createTextNode(string), ec);
         ASSERT(!ec);
-        if (string.endsWith("\n")) {
+        if (string.endsWith('\n')) {
             RefPtr<Element> element = createBreakElement(document);
             element->setAttribute(classAttr, AppleInterchangeNewline);            
             fragment->appendChild(element.release(), ec);

Modified: trunk/Source/WebCore/html/HTMLObjectElement.cpp (115668 => 115669)


--- trunk/Source/WebCore/html/HTMLObjectElement.cpp	2012-04-30 21:30:56 UTC (rev 115668)
+++ trunk/Source/WebCore/html/HTMLObjectElement.cpp	2012-04-30 21:32:44 UTC (rev 115669)
@@ -476,7 +476,7 @@
     // FIXME: Passing a string that starts with "#" to the completeURL function does
     // not seem like it would work. The image element has similar but not identical code.
     const AtomicString& useMap = ""
-    if (useMap.startsWith("#"))
+    if (useMap.startsWith('#'))
         addSubresourceURL(urls, document()->completeURL(useMap));
 }
 

Modified: trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp (115668 => 115669)


--- trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp	2012-04-30 21:30:56 UTC (rev 115668)
+++ trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp	2012-04-30 21:32:44 UTC (rev 115669)
@@ -473,7 +473,7 @@
         innerTextElement()->setInnerText(value, ec);
         ASSERT(!ec);
 
-        if (value.endsWith("\n") || value.endsWith("\r")) {
+        if (value.endsWith('\n') || value.endsWith('\r')) {
             innerTextElement()->appendChild(HTMLBRElement::create(document()), ec);
             ASSERT(!ec);
         }

Modified: trunk/Source/WebCore/inspector/ContentSearchUtils.cpp (115668 => 115669)


--- trunk/Source/WebCore/inspector/ContentSearchUtils.cpp	2012-04-30 21:30:56 UTC (rev 115668)
+++ trunk/Source/WebCore/inspector/ContentSearchUtils.cpp	2012-04-30 21:32:44 UTC (rev 115669)
@@ -81,7 +81,7 @@
         String line = text.substring(start, lineEnd - start);
         if (line.endsWith("\r\n"))
             line = line.left(line.length() - 2);
-        if (line.endsWith("\n"))
+        if (line.endsWith('\n'))
             line = line.left(line.length() - 1);
 
         int matchLength;

Modified: trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp (115668 => 115669)


--- trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp	2012-04-30 21:30:56 UTC (rev 115668)
+++ trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp	2012-04-30 21:32:44 UTC (rev 115669)
@@ -321,7 +321,7 @@
         bool result = m_styleSheet->setPropertyText(m_cssId, m_propertyIndex, m_text, m_overwrite, &oldText, ec);
         m_oldText = oldText.stripWhiteSpace();
         // FIXME: remove this once the model handles this case.
-        if (!m_oldText.endsWith(";"))
+        if (!m_oldText.endsWith(';'))
             m_oldText += ";";
         return result;
     }

Modified: trunk/Source/WebCore/loader/MainResourceLoader.cpp (115668 => 115669)


--- trunk/Source/WebCore/loader/MainResourceLoader.cpp	2012-04-30 21:30:56 UTC (rev 115668)
+++ trunk/Source/WebCore/loader/MainResourceLoader.cpp	2012-04-30 21:32:44 UTC (rev 115669)
@@ -342,7 +342,7 @@
         return;
 
     String filename = r.url().lastPathComponent();
-    if (filename.endsWith("/"))
+    if (filename.endsWith('/'))
         return;
 
     size_t extensionPos = filename.reverseFind('.');

Modified: trunk/Source/WebCore/loader/appcache/ManifestParser.cpp (115668 => 115669)


--- trunk/Source/WebCore/loader/appcache/ManifestParser.cpp	2012-04-30 21:30:56 UTC (rev 115668)
+++ trunk/Source/WebCore/loader/appcache/ManifestParser.cpp	2012-04-30 21:32:44 UTC (rev 115669)
@@ -96,7 +96,7 @@
             mode = Fallback;
         else if (line == "NETWORK:")
             mode = OnlineWhitelist;
-        else if (line.endsWith(":"))
+        else if (line.endsWith(':'))
             mode = Unknown;
         else if (mode == Unknown)
             continue;

Modified: trunk/Source/WebCore/platform/blackberry/CookieManager.cpp (115668 => 115669)


--- trunk/Source/WebCore/platform/blackberry/CookieManager.cpp	2012-04-30 21:30:56 UTC (rev 115668)
+++ trunk/Source/WebCore/platform/blackberry/CookieManager.cpp	2012-04-30 21:32:44 UTC (rev 115669)
@@ -184,7 +184,7 @@
     // a.b.com matches b.com, a.b.com matches .B.com and a.b.com matches .A.b.Com
     // and so on.
     String hostDomainName = url.host();
-    hostDomainName = hostDomainName.startsWith(".") ? hostDomainName : "." + hostDomainName;
+    hostDomainName = hostDomainName.startsWith('.') ? hostDomainName : "." + hostDomainName;
     if (!hostDomainName.endsWith(cookie->domain(), false)) {
         LOG_ERROR("Cookie %s is rejected because its domain does not domain match the URL %s\n", cookie->toString().utf8().data(), url.string().utf8().data());
         return true;

Modified: trunk/Source/WebCore/platform/posix/FileSystemPOSIX.cpp (115668 => 115669)


--- trunk/Source/WebCore/platform/posix/FileSystemPOSIX.cpp	2012-04-30 21:30:56 UTC (rev 115668)
+++ trunk/Source/WebCore/platform/posix/FileSystemPOSIX.cpp	2012-04-30 21:32:44 UTC (rev 115669)
@@ -183,10 +183,9 @@
 
 String pathByAppendingComponent(const String& path, const String& component)
 {
-    if (path.endsWith("/"))
+    if (path.endsWith('/'))
         return path + component;
-    else
-        return path + "/" + component;
+    return path + "/" + component;
 }
 
 bool makeAllDirectories(const String& path)

Modified: trunk/Source/WebCore/plugins/PluginDatabase.cpp (115668 => 115669)


--- trunk/Source/WebCore/plugins/PluginDatabase.cpp	2012-04-30 21:30:56 UTC (rev 115668)
+++ trunk/Source/WebCore/plugins/PluginDatabase.cpp	2012-04-30 21:32:44 UTC (rev 115669)
@@ -283,7 +283,7 @@
         return pluginForMIMEType(mimeType);
     
     String filename = url.lastPathComponent();
-    if (filename.endsWith("/"))
+    if (filename.endsWith('/'))
         return 0;
     
     int extensionPos = filename.reverseFind('.');

Modified: trunk/Source/WebCore/svg/SVGStopElement.cpp (115668 => 115669)


--- trunk/Source/WebCore/svg/SVGStopElement.cpp	2012-04-30 21:30:56 UTC (rev 115668)
+++ trunk/Source/WebCore/svg/SVGStopElement.cpp	2012-04-30 21:32:44 UTC (rev 115669)
@@ -71,7 +71,7 @@
 
     if (attr->name() == SVGNames::offsetAttr) {
         const String& value = attr->value();
-        if (value.endsWith("%"))
+        if (value.endsWith('%'))
             setOffsetBaseValue(value.left(value.length() - 1).toFloat() / 100.0f);
         else
             setOffsetBaseValue(value.toFloat());

Modified: trunk/Source/WebCore/svg/animation/SVGSMILElement.cpp (115668 => 115669)


--- trunk/Source/WebCore/svg/animation/SVGSMILElement.cpp	2012-04-30 21:30:56 UTC (rev 115668)
+++ trunk/Source/WebCore/svg/animation/SVGSMILElement.cpp	2012-04-30 21:32:44 UTC (rev 115669)
@@ -248,13 +248,13 @@
     bool ok;
     double result = 0;
     String parse = data.stripWhiteSpace();
-    if (parse.endsWith("h"))
+    if (parse.endsWith('h'))
         result = parse.left(parse.length() - 1).toDouble(&ok) * 60 * 60;
     else if (parse.endsWith("min"))
         result = parse.left(parse.length() - 3).toDouble(&ok) * 60;
     else if (parse.endsWith("ms"))
         result = parse.left(parse.length() - 2).toDouble(&ok) / 1000;
-    else if (parse.endsWith("s"))
+    else if (parse.endsWith('s'))
         result = parse.left(parse.length() - 1).toDouble(&ok);
     else
         result = parse.toDouble(&ok);
@@ -345,7 +345,7 @@
 
     Condition::Type type;
     int repeats = -1;
-    if (nameString.startsWith("repeat(") && nameString.endsWith(")")) {
+    if (nameString.startsWith("repeat(") && nameString.endsWith(')')) {
         // FIXME: For repeat events we just need to add the data carrying TimeEvent class and 
         // fire the events at appropiate times.
         repeats = nameString.substring(7, nameString.length() - 8).toUIntStrict(&ok);

Modified: trunk/Source/WebKit/blackberry/ChangeLog (115668 => 115669)


--- trunk/Source/WebKit/blackberry/ChangeLog	2012-04-30 21:30:56 UTC (rev 115668)
+++ trunk/Source/WebKit/blackberry/ChangeLog	2012-04-30 21:32:44 UTC (rev 115669)
@@ -1,3 +1,13 @@
+2012-04-30  Benjamin Poulain  <[email protected]>
+
+        Add String::startsWith() and endsWith() for string literals
+        https://bugs.webkit.org/show_bug.cgi?id=85154
+
+        Reviewed by Darin Adler.
+
+        * WebKitSupport/DOMSupport.cpp:
+        (BlackBerry::WebKit::DOMSupport::elementPatternMatches):
+
 2012-04-27  Jacky Jiang  <[email protected]>
 
         [BlackBerry] Double tap zooming does nothing on table element on bustedtees.com

Modified: trunk/Source/WebKit/blackberry/WebKitSupport/DOMSupport.cpp (115668 => 115669)


--- trunk/Source/WebKit/blackberry/WebKitSupport/DOMSupport.cpp	2012-04-30 21:30:56 UTC (rev 115668)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/DOMSupport.cpp	2012-04-30 21:32:44 UTC (rev 115669)
@@ -424,7 +424,7 @@
                 return true;
 
             // Is the regex specifying a character count?
-            if (patternAttribute[patternString.length()] != '{' || !patternAttribute.endsWith("}"))
+            if (patternAttribute[patternString.length()] != '{' || !patternAttribute.endsWith('}'))
                 return false;
 
             // Make sure the number in the regex is actually a number.

Modified: trunk/Source/WebKit2/ChangeLog (115668 => 115669)


--- trunk/Source/WebKit2/ChangeLog	2012-04-30 21:30:56 UTC (rev 115668)
+++ trunk/Source/WebKit2/ChangeLog	2012-04-30 21:32:44 UTC (rev 115669)
@@ -1,3 +1,15 @@
+2012-04-30  Benjamin Poulain  <[email protected]>
+
+        Add String::startsWith() and endsWith() for string literals
+        https://bugs.webkit.org/show_bug.cgi?id=85154
+
+        Reviewed by Darin Adler.
+
+        Update WebKit2 to use String::endsWith(UChar).
+
+        * UIProcess/Plugins/PluginInfoStore.cpp:
+        (WebKit::pathExtension):
+
 2012-04-30  Alexey Proskuryakov  <[email protected]>
 
         Validate keypress command names

Modified: trunk/Source/WebKit2/UIProcess/Plugins/PluginInfoStore.cpp (115668 => 115669)


--- trunk/Source/WebKit2/UIProcess/Plugins/PluginInfoStore.cpp	2012-04-30 21:30:56 UTC (rev 115668)
+++ trunk/Source/WebKit2/UIProcess/Plugins/PluginInfoStore.cpp	2012-04-30 21:32:44 UTC (rev 115669)
@@ -164,7 +164,7 @@
 {
     String extension;
     String filename = url.lastPathComponent();
-    if (!filename.endsWith("/")) {
+    if (!filename.endsWith('/')) {
         int extensionPos = filename.reverseFind('.');
         if (extensionPos != -1)
             extension = filename.substring(extensionPos + 1);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to