Use more efficient path resolution logic
authorbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 3 May 2019 19:42:53 +0000 (19:42 +0000)
committerbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 3 May 2019 19:42:53 +0000 (19:42 +0000)
commitd28875166fe64a2e00704068ce026f4d73daa133
tree7a2c6229f35358870280eed1198adec47ac4ce64
parentf75d7f1383269a3de4fd9148df20863e4c2942e5
Use more efficient path resolution logic
https://bugs.webkit.org/show_bug.cgi?id=197389
<rdar://problem/50268491>

Reviewed by Maciej Stachowiak.

The code in SandboxExtensionsCocoa.mm 'resolveSymlinksInPath' is pretty inefficient, and tries to reproduce (badly)
logic that is already provided by the operating system.

To make matters worse, 'resolvePathForSandboxExtension' was effectively performing the work of fully resolving
symlinks twice, since NSString's 'stringByStandardizingPath' method does some of this already.

Instead, we should just use NSString's 'stringByResolvingSymlinksInPath', which does the symlink resolution
using more efficient logic than our 'resolveSymlinksInPath' code.

* Shared/Cocoa/SandboxExtensionCocoa.mm:
(WebKit::resolveSymlinksInPath): Removed.
(WebKit::resolvePathForSandboxExtension): Remove redundant call to 'resolveSymlinksInPath', and switches from
'stringByStandardizingPath' to 'stringByResolvingSymlinksInPath', which can take the place of both calls.
(WebKit::stringByResolvingSymlinksInPath): Switch to call 'stringByResolvingSymlinksInPath'.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@244917 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebKit/ChangeLog
Source/WebKit/Shared/Cocoa/SandboxExtensionCocoa.mm