Skip to content

Commit 87a0f52

Browse files
committed
minor #15614 consistently use str_replace to unify directory separators (Tobion)
This PR was merged into the 2.3 branch. Discussion ---------- consistently use str_replace to unify directory separators | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | - We used a mix of `str_replace` and `strtr` for the same thing. `str_replace` is faster as [I tested myself](https://3v4l.org/MNrgC) which is logical since strtr adds logic we don't need here. Commits ------- b9760ef consistently use str_replace to unify directory separators
2 parents a7bd522 + 23d5774 commit 87a0f52

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

Iterator/ExcludeDirectoryFilterIterator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function __construct(\Iterator $iterator, array $directories)
4444
public function accept()
4545
{
4646
$path = $this->isDir() ? $this->current()->getRelativePathname() : $this->current()->getRelativePath();
47-
$path = strtr($path, '\\', '/');
47+
$path = str_replace('\\', '/', $path);
4848
foreach ($this->patterns as $pattern) {
4949
if (preg_match($pattern, $path)) {
5050
return false;

Iterator/PathFilterIterator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function accept()
2929
$filename = $this->current()->getRelativePathname();
3030

3131
if ('\\' === DIRECTORY_SEPARATOR) {
32-
$filename = strtr($filename, '\\', '/');
32+
$filename = str_replace('\\', '/', $filename);
3333
}
3434

3535
// should at least not match one rule to exclude

0 commit comments

Comments
 (0)