Skip to content

Commit 9b4c90c

Browse files
authored
Merge pull request #385 from jfcherng/final
Performance improvement for Directory::getAbsolutePath()
2 parents 77824bc + ab7b2d7 commit 9b4c90c

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/phpFastCache/Util/Directory.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,7 @@ public static function rrmdir($source, $removeOnlyChildren = false)
120120
*/
121121
public static function getAbsolutePath($path)
122122
{
123-
$path = str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $path);
124-
$parts = array_filter(explode(DIRECTORY_SEPARATOR, $path), 'strlen');
123+
$parts = preg_split('~[/\\\\]+~', $path, 0, PREG_SPLIT_NO_EMPTY);
125124
$absolutes = [];
126125
foreach ($parts as $part) {
127126
if ('.' === $part) {

0 commit comments

Comments
 (0)