Title: [232088] trunk/Source/WebCore
Revision
232088
Author
[email protected]
Date
2018-05-22 16:54:04 -0700 (Tue, 22 May 2018)

Log Message

[POSIX] Use access() instead of stat() in FileSystem::fileExists()
https://bugs.webkit.org/show_bug.cgi?id=185882

Reviewed by Geoffrey Garen.

Use access() instead of stat() in FileSystem::fileExists(). stat() returns a lot of information we
do not leverage and local benchmarking on macOS shows access() being > 80% faster than stat():
stat: 0.31567 (lower is better)
access: 0.16074 (lower is better)
stat: 0.303665 (lower is better)
access: 0.165468 (lower is better)

* platform/posix/FileSystemPOSIX.cpp:
(WebCore::FileSystem::fileExists):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (232087 => 232088)


--- trunk/Source/WebCore/ChangeLog	2018-05-22 23:45:59 UTC (rev 232087)
+++ trunk/Source/WebCore/ChangeLog	2018-05-22 23:54:04 UTC (rev 232088)
@@ -1,3 +1,20 @@
+2018-05-22  Chris Dumez  <[email protected]>
+
+        [POSIX] Use access() instead of stat() in FileSystem::fileExists()
+        https://bugs.webkit.org/show_bug.cgi?id=185882
+
+        Reviewed by Geoffrey Garen.
+
+        Use access() instead of stat() in FileSystem::fileExists(). stat() returns a lot of information we
+        do not leverage and local benchmarking on macOS shows access() being > 80% faster than stat():
+        stat: 0.31567 (lower is better)
+        access: 0.16074 (lower is better)
+        stat: 0.303665 (lower is better)
+        access: 0.165468 (lower is better)
+
+        * platform/posix/FileSystemPOSIX.cpp:
+        (WebCore::FileSystem::fileExists):
+
 2018-05-22  Brent Fulgham  <[email protected]>
 
         Avoid keeping FormState alive longer than necessary

Modified: trunk/Source/WebCore/platform/posix/FileSystemPOSIX.cpp (232087 => 232088)


--- trunk/Source/WebCore/platform/posix/FileSystemPOSIX.cpp	2018-05-22 23:45:59 UTC (rev 232087)
+++ trunk/Source/WebCore/platform/posix/FileSystemPOSIX.cpp	2018-05-22 23:54:04 UTC (rev 232088)
@@ -58,10 +58,7 @@
     if (!fsRep.data() || fsRep.data()[0] == '\0')
         return false;
 
-    struct stat fileInfo;
-
-    // stat(...) returns 0 on successful stat'ing of the file, and non-zero in any case where the file doesn't exist or cannot be accessed
-    return !stat(fsRep.data(), &fileInfo);
+    return access(fsRep.data(), F_OK) != -1;
 }
 
 bool deleteFile(const String& path)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to