Improve performance on psr4 autoload file finding
parent
f85a4a2f51
commit
e6d648f465
|
@ -374,9 +374,13 @@ class ClassLoader
|
||||||
|
|
||||||
$first = $class[0];
|
$first = $class[0];
|
||||||
if (isset($this->prefixLengthsPsr4[$first])) {
|
if (isset($this->prefixLengthsPsr4[$first])) {
|
||||||
foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) {
|
$subPath = $class;
|
||||||
if (0 === strpos($class, $prefix)) {
|
while (false !== $lastPos = strrpos($subPath, '\\')) {
|
||||||
foreach ($this->prefixDirsPsr4[$prefix] as $dir) {
|
$subPath = substr($subPath, 0, $lastPos);
|
||||||
|
$search = $subPath.'\\';
|
||||||
|
if (isset($this->prefixDirsPsr4[$search])) {
|
||||||
|
foreach ($this->prefixDirsPsr4[$search] as $dir) {
|
||||||
|
$length = $this->prefixLengthsPsr4[$first][$search];
|
||||||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) {
|
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) {
|
||||||
return $file;
|
return $file;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue