Merge pull request #4672 from Tobion/patch-1
[ClassLoader] performance improvement: use str_replace instead of strtrpull/4684/head
commit
44bc8e019f
|
@ -344,7 +344,7 @@ class ClassLoader
|
||||||
private function findFileWithExtension($class, $ext)
|
private function findFileWithExtension($class, $ext)
|
||||||
{
|
{
|
||||||
// PSR-4 lookup
|
// PSR-4 lookup
|
||||||
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
|
$logicalPathPsr4 = ('\\' !== DIRECTORY_SEPARATOR ? str_replace('\\', DIRECTORY_SEPARATOR, $class) : $class) . $ext;
|
||||||
|
|
||||||
$first = $class[0];
|
$first = $class[0];
|
||||||
if (isset($this->prefixLengthsPsr4[$first])) {
|
if (isset($this->prefixLengthsPsr4[$first])) {
|
||||||
|
@ -370,10 +370,10 @@ class ClassLoader
|
||||||
if (false !== $pos = strrpos($class, '\\')) {
|
if (false !== $pos = strrpos($class, '\\')) {
|
||||||
// namespaced class name
|
// namespaced class name
|
||||||
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
|
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
|
||||||
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
|
. str_replace('_', DIRECTORY_SEPARATOR, substr($logicalPathPsr4, $pos + 1));
|
||||||
} else {
|
} else {
|
||||||
// PEAR-like class name
|
// PEAR-like class name
|
||||||
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
|
$logicalPathPsr0 = str_replace('_', DIRECTORY_SEPARATOR, $class) . $ext;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($this->prefixesPsr0[$first])) {
|
if (isset($this->prefixesPsr0[$first])) {
|
||||||
|
|
Loading…
Reference in New Issue