Title: [164124] trunk/Source
Revision
164124
Author
benja...@webkit.org
Date
2014-02-14 12:59:27 -0800 (Fri, 14 Feb 2014)

Log Message

Improve the performance on mobile of FTPDirectoryDocument
https://bugs.webkit.org/show_bug.cgi?id=128778

Patch by Benjamin Poulain <bpoul...@apple.com> on 2014-02-14
Reviewed by Antti Koivisto.

Source/WebCore: 

Little cleanup.

* html/FTPDirectoryDocument.cpp:
(WebCore::FTPDirectoryDocumentParser::appendEntry):
(WebCore::FTPDirectoryDocumentParser::createTDForFilename):
(WebCore::processFilesizeString):
(WebCore::wasLastDayOfMonth):
(WebCore::processFileDateString):
(WebCore::FTPDirectoryDocumentParser::parseAndAppendOneLine):
(WebCore::FTPDirectoryDocumentParser::loadDocumentTemplate):
(WebCore::FTPDirectoryDocumentParser::createBasicDocument):

Source/WTF: 

* wtf/text/WTFString.h:
(WTF::String::endsWith): add a missing overload.

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (164123 => 164124)


--- trunk/Source/WTF/ChangeLog	2014-02-14 20:58:28 UTC (rev 164123)
+++ trunk/Source/WTF/ChangeLog	2014-02-14 20:59:27 UTC (rev 164124)
@@ -1,3 +1,13 @@
+2014-02-14  Benjamin Poulain  <bpoul...@apple.com>
+
+        Improve the performance on mobile of FTPDirectoryDocument
+        https://bugs.webkit.org/show_bug.cgi?id=128778
+
+        Reviewed by Antti Koivisto.
+
+        * wtf/text/WTFString.h:
+        (WTF::String::endsWith): add a missing overload.
+
 2014-02-14  Wojciech Bielawski  <w.bielaw...@samsung.com>
 
         (try)append and insert operations don't need new operator for PODs

Modified: trunk/Source/WTF/wtf/text/WTFString.h (164123 => 164124)


--- trunk/Source/WTF/wtf/text/WTFString.h	2014-02-14 20:58:28 UTC (rev 164123)
+++ trunk/Source/WTF/wtf/text/WTFString.h	2014-02-14 20:59:27 UTC (rev 164124)
@@ -284,6 +284,7 @@
         { return m_impl ? m_impl->endsWith(s.impl(), caseSensitive) : s.isEmpty(); }
     bool endsWith(UChar character) const
         { return m_impl ? m_impl->endsWith(character) : false; }
+    bool endsWith(char character) const { return endsWith(static_cast<UChar>(character)); }
     template<unsigned matchLength>
     bool endsWith(const char (&prefix)[matchLength], bool caseSensitive = true) const
         { return m_impl ? m_impl->endsWith<matchLength>(prefix, caseSensitive) : !matchLength; }

Modified: trunk/Source/WebCore/ChangeLog (164123 => 164124)


--- trunk/Source/WebCore/ChangeLog	2014-02-14 20:58:28 UTC (rev 164123)
+++ trunk/Source/WebCore/ChangeLog	2014-02-14 20:59:27 UTC (rev 164124)
@@ -1,3 +1,22 @@
+2014-02-14  Benjamin Poulain  <bpoul...@apple.com>
+
+        Improve the performance on mobile of FTPDirectoryDocument
+        https://bugs.webkit.org/show_bug.cgi?id=128778
+
+        Reviewed by Antti Koivisto.
+
+        Little cleanup.
+
+        * html/FTPDirectoryDocument.cpp:
+        (WebCore::FTPDirectoryDocumentParser::appendEntry):
+        (WebCore::FTPDirectoryDocumentParser::createTDForFilename):
+        (WebCore::processFilesizeString):
+        (WebCore::wasLastDayOfMonth):
+        (WebCore::processFileDateString):
+        (WebCore::FTPDirectoryDocumentParser::parseAndAppendOneLine):
+        (WebCore::FTPDirectoryDocumentParser::loadDocumentTemplate):
+        (WebCore::FTPDirectoryDocumentParser::createBasicDocument):
+
 2014-02-14  Benjamin Poulain  <benja...@webkit.org>
 
         Do not attempt to synchronize attributes when no Simple Selector could match an animatable attribute

Modified: trunk/Source/WebCore/html/FTPDirectoryDocument.cpp (164123 => 164124)


--- trunk/Source/WebCore/html/FTPDirectoryDocument.cpp	2014-02-14 20:58:28 UTC (rev 164123)
+++ trunk/Source/WebCore/html/FTPDirectoryDocument.cpp	2014-02-14 20:59:27 UTC (rev 164124)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2007, 2008, 2014 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -107,41 +107,41 @@
 void FTPDirectoryDocumentParser::appendEntry(const String& filename, const String& size, const String& date, bool isDirectory)
 {
     RefPtr<Element> rowElement = m_tableElement->insertRow(-1, IGNORE_EXCEPTION);
-    rowElement->setAttribute("class", "ftpDirectoryEntryRow", IGNORE_EXCEPTION);
+    rowElement->setAttribute(HTMLNames::classAttr, "ftpDirectoryEntryRow");
 
     RefPtr<Element> element = document()->createElement(tdTag, false);
     element->appendChild(Text::create(*document(), String(&noBreakSpace, 1)), IGNORE_EXCEPTION);
     if (isDirectory)
-        element->setAttribute("class", "ftpDirectoryIcon ftpDirectoryTypeDirectory", IGNORE_EXCEPTION);
+        element->setAttribute(HTMLNames::classAttr, "ftpDirectoryIcon ftpDirectoryTypeDirectory");
     else
-        element->setAttribute("class", "ftpDirectoryIcon ftpDirectoryTypeFile", IGNORE_EXCEPTION);
+        element->setAttribute(HTMLNames::classAttr, "ftpDirectoryIcon ftpDirectoryTypeFile");
     rowElement->appendChild(element, IGNORE_EXCEPTION);
 
     element = createTDForFilename(filename);
-    element->setAttribute("class", "ftpDirectoryFileName", IGNORE_EXCEPTION);
+    element->setAttribute(HTMLNames::classAttr, "ftpDirectoryFileName");
     rowElement->appendChild(element, IGNORE_EXCEPTION);
 
     element = document()->createElement(tdTag, false);
     element->appendChild(Text::create(*document(), date), IGNORE_EXCEPTION);
-    element->setAttribute("class", "ftpDirectoryFileDate", IGNORE_EXCEPTION);
+    element->setAttribute(HTMLNames::classAttr, "ftpDirectoryFileDate");
     rowElement->appendChild(element, IGNORE_EXCEPTION);
 
     element = document()->createElement(tdTag, false);
     element->appendChild(Text::create(*document(), size), IGNORE_EXCEPTION);
-    element->setAttribute("class", "ftpDirectoryFileSize", IGNORE_EXCEPTION);
+    element->setAttribute(HTMLNames::classAttr, "ftpDirectoryFileSize");
     rowElement->appendChild(element, IGNORE_EXCEPTION);
 }
 
 PassRefPtr<Element> FTPDirectoryDocumentParser::createTDForFilename(const String& filename)
 {
     String fullURL = document()->baseURL().string();
-    if (fullURL[fullURL.length() - 1] == '/')
+    if (fullURL.endsWith('/'))
         fullURL.append(filename);
     else
-        fullURL.append("/" + filename);
+        fullURL.append(makeString('/', filename));
 
     RefPtr<Element> anchorElement = document()->createElement(aTag, false);
-    anchorElement->setAttribute("href", fullURL, IGNORE_EXCEPTION);
+    anchorElement->setAttribute(HTMLNames::hrefAttr, fullURL);
     anchorElement->appendChild(Text::create(*document(), filename), IGNORE_EXCEPTION);
 
     RefPtr<Element> tdElement = document()->createElement(tdTag, false);
@@ -153,7 +153,7 @@
 static String processFilesizeString(const String& size, bool isDirectory)
 {
     if (isDirectory)
-        return "--";
+        return ASCIILiteral("--");
 
     bool valid;
     int64_t bytes = size.toUInt64(&valid);
@@ -171,7 +171,7 @@
 
 static bool wasLastDayOfMonth(int year, int month, int day)
 {
-    static int lastDays[] = { 31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
+    static const int lastDays[] = { 31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
     if (month < 0 || month > 11)
         return false;
 
@@ -241,9 +241,9 @@
     String dateString;
 
     if (fileTime.tm_year > -1)
-        dateString = String(months[month]) + " " + String::number(fileTime.tm_mday) + ", " + String::number(fileTime.tm_year);
+        dateString = makeString(months[month], ' ', String::number(fileTime.tm_mday), ", ", String::number(fileTime.tm_year));
     else
-        dateString = String(months[month]) + " " + String::number(fileTime.tm_mday) + ", " + String::number(now.year());
+        dateString = makeString(months[month], ' ', String::number(fileTime.tm_mday), ", ", String::number(now.year()));
 
     return dateString + timeOfDay;
 }
@@ -261,7 +261,7 @@
 
     String filename(result.filename, result.filenameLength);
     if (result.type == FTPDirectoryEntry) {
-        filename.append("/");
+        filename.append('/');
 
         // We have no interest in linking to "current directory"
         if (filename == "./")
@@ -312,7 +312,7 @@
     // Otherwise create one manually
     tableElement = document()->createElement(tableTag, false);
     m_tableElement = toHTMLTableElement(tableElement.get());
-    m_tableElement->setAttribute("id", "ftpDirectoryTable", IGNORE_EXCEPTION);
+    m_tableElement->setAttribute(HTMLNames::idAttr, "ftpDirectoryTable");
 
     // If we didn't find the table element, lets try to append our own to the body
     // If that fails for some reason, cram it on the end of the document as a last
@@ -337,7 +337,7 @@
 
     RefPtr<Element> tableElement = document()->createElement(tableTag, false);
     m_tableElement = toHTMLTableElement(tableElement.get());
-    m_tableElement->setAttribute("id", "ftpDirectoryTable", IGNORE_EXCEPTION);
+    m_tableElement->setAttribute(HTMLNames::idAttr, "ftpDirectoryTable");
 
     bodyElement->appendChild(m_tableElement, IGNORE_EXCEPTION);
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to