Title: [221608] trunk/Source/WebCore
Revision
221608
Author
[email protected]
Date
2017-09-04 21:55:29 -0700 (Mon, 04 Sep 2017)

Log Message

Use StringView more in DOMFileSystem code
https://bugs.webkit.org/show_bug.cgi?id=176347

Reviewed by Darin Adler.

* Modules/entriesapi/DOMFileSystem.cpp:
(WebCore::resolveRelativeVirtualPath):
(WebCore::DOMFileSystem::evaluatePath):
* platform/FileSystem.h:
* platform/glib/FileSystemGlib.cpp:
(WebCore::pathByAppendingComponents):
* platform/posix/FileSystemPOSIX.cpp:
(WebCore::pathByAppendingComponents):
* platform/win/FileSystemWin.cpp:
(WebCore::pathByAppendingComponents):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (221607 => 221608)


--- trunk/Source/WebCore/ChangeLog	2017-09-05 04:10:53 UTC (rev 221607)
+++ trunk/Source/WebCore/ChangeLog	2017-09-05 04:55:29 UTC (rev 221608)
@@ -1,3 +1,21 @@
+2017-09-04  Chris Dumez  <[email protected]>
+
+        Use StringView more in DOMFileSystem code
+        https://bugs.webkit.org/show_bug.cgi?id=176347
+
+        Reviewed by Darin Adler.
+
+        * Modules/entriesapi/DOMFileSystem.cpp:
+        (WebCore::resolveRelativeVirtualPath):
+        (WebCore::DOMFileSystem::evaluatePath):
+        * platform/FileSystem.h:
+        * platform/glib/FileSystemGlib.cpp:
+        (WebCore::pathByAppendingComponents):
+        * platform/posix/FileSystemPOSIX.cpp:
+        (WebCore::pathByAppendingComponents):
+        * platform/win/FileSystemWin.cpp:
+        (WebCore::pathByAppendingComponents):
+
 2017-09-04  Eric Carlson  <[email protected]>
 
         Switch HTMLMediaElement to release logging

Modified: trunk/Source/WebCore/Modules/entriesapi/DOMFileSystem.cpp (221607 => 221608)


--- trunk/Source/WebCore/Modules/entriesapi/DOMFileSystem.cpp	2017-09-05 04:10:53 UTC (rev 221607)
+++ trunk/Source/WebCore/Modules/entriesapi/DOMFileSystem.cpp	2017-09-05 04:55:29 UTC (rev 221608)
@@ -174,15 +174,17 @@
 }
 
 // https://wicg.github.io/entries-api/#resolve-a-relative-path
-static String resolveRelativeVirtualPath(const String& baseVirtualPath, StringView relativeVirtualPath)
+static String resolveRelativeVirtualPath(StringView baseVirtualPath, StringView relativeVirtualPath)
 {
     ASSERT(baseVirtualPath[0] == '/');
     if (relativeVirtualPath[0] == '/')
-        return relativeVirtualPath.length() == 1 ? relativeVirtualPath.toString() : resolveRelativeVirtualPath(ASCIILiteral("/"), relativeVirtualPath.substring(1));
+        return relativeVirtualPath.length() == 1 ? relativeVirtualPath.toString() : resolveRelativeVirtualPath("/", relativeVirtualPath.substring(1));
 
-    auto virtualPathSegments = baseVirtualPath.split('/');
-    auto relativePathSegments = relativeVirtualPath.split('/');
-    for (auto segment : relativePathSegments) {
+    Vector<StringView> virtualPathSegments;
+    for (auto segment : baseVirtualPath.split('/'))
+        virtualPathSegments.append(segment);
+
+    for (auto segment : relativeVirtualPath.split('/')) {
         ASSERT(!segment.isEmpty());
         if (segment == ".")
             continue;
@@ -191,7 +193,7 @@
                 virtualPathSegments.removeLast();
             continue;
         }
-        virtualPathSegments.append(segment.toStringWithoutCopying());
+        virtualPathSegments.append(segment);
     }
 
     if (virtualPathSegments.isEmpty())
@@ -209,10 +211,9 @@
 String DOMFileSystem::evaluatePath(StringView virtualPath)
 {
     ASSERT(virtualPath[0] == '/');
-    auto components = virtualPath.split('/');
 
-    Vector<String> resolvedComponents;
-    for (auto component : components) {
+    Vector<StringView> resolvedComponents;
+    for (auto component : virtualPath.split('/')) {
         if (component == ".")
             continue;
         if (component == "..") {
@@ -220,7 +221,7 @@
                 resolvedComponents.removeLast();
             continue;
         }
-        resolvedComponents.append(component.toStringWithoutCopying());
+        resolvedComponents.append(component);
     }
 
     return pathByAppendingComponents(m_rootPath, resolvedComponents);

Modified: trunk/Source/WebCore/platform/FileSystem.h (221607 => 221608)


--- trunk/Source/WebCore/platform/FileSystem.h	2017-09-05 04:10:53 UTC (rev 221607)
+++ trunk/Source/WebCore/platform/FileSystem.h	2017-09-05 04:55:29 UTC (rev 221608)
@@ -104,7 +104,7 @@
 WEBCORE_EXPORT std::optional<FileMetadata> fileMetadataFollowingSymlinks(const String& path);
 bool fileIsDirectory(const String&, ShouldFollowSymbolicLinks);
 WEBCORE_EXPORT String pathByAppendingComponent(const String& path, const String& component);
-String pathByAppendingComponents(const String& path, const Vector<String>& components);
+String pathByAppendingComponents(StringView path, const Vector<StringView>& components);
 String lastComponentOfPathIgnoringTrailingSlash(const String& path);
 WEBCORE_EXPORT bool makeAllDirectories(const String& path);
 String homeDirectoryPath();

Modified: trunk/Source/WebCore/platform/glib/FileSystemGlib.cpp (221607 => 221608)


--- trunk/Source/WebCore/platform/glib/FileSystemGlib.cpp	2017-09-05 04:10:53 UTC (rev 221607)
+++ trunk/Source/WebCore/platform/glib/FileSystemGlib.cpp	2017-09-05 04:55:29 UTC (rev 221608)
@@ -207,7 +207,7 @@
     return path + G_DIR_SEPARATOR_S + component;
 }
 
-String pathByAppendingComponents(const String& path, const Vector<String>& components)
+String pathByAppendingComponents(StringView path, const Vector<StringView>& components)
 {
     StringBuilder builder;
     builder.append(path);

Modified: trunk/Source/WebCore/platform/posix/FileSystemPOSIX.cpp (221607 => 221608)


--- trunk/Source/WebCore/platform/posix/FileSystemPOSIX.cpp	2017-09-05 04:10:53 UTC (rev 221607)
+++ trunk/Source/WebCore/platform/posix/FileSystemPOSIX.cpp	2017-09-05 04:55:29 UTC (rev 221608)
@@ -299,7 +299,7 @@
     return path + "/" + component;
 }
 
-String pathByAppendingComponents(const String& path, const Vector<String>& components)
+String pathByAppendingComponents(StringView path, const Vector<StringView>& components)
 {
     StringBuilder builder;
     builder.append(path);

Modified: trunk/Source/WebCore/platform/win/FileSystemWin.cpp (221607 => 221608)


--- trunk/Source/WebCore/platform/win/FileSystemWin.cpp	2017-09-05 04:10:53 UTC (rev 221607)
+++ trunk/Source/WebCore/platform/win/FileSystemWin.cpp	2017-09-05 04:55:29 UTC (rev 221608)
@@ -263,7 +263,7 @@
     return String::adopt(WTFMove(buffer));
 }
 
-String pathByAppendingComponents(const String& path, const Vector<String>& components)
+String pathByAppendingComponents(StringView path, const Vector<StringView>& components)
 {
     String result = path;
     for (auto& component : components)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to