Commit 769acfbd by Qiang Xue

Merge pull request #550 from cebe/speed

Improve application speed by using classMap for autoloader
parents 7dfae28b 2fa52d8c
...@@ -23,3 +23,4 @@ class Yii extends \yii\YiiBase ...@@ -23,3 +23,4 @@ class Yii extends \yii\YiiBase
} }
spl_autoload_register(array('Yii', 'autoload')); spl_autoload_register(array('Yii', 'autoload'));
Yii::$classMap = include(__DIR__ . '/classes.php');
...@@ -337,9 +337,9 @@ class YiiBase ...@@ -337,9 +337,9 @@ class YiiBase
$className = ltrim($className, '\\'); $className = ltrim($className, '\\');
if (isset(self::$classMap[$className])) { if (isset(self::$classMap[$className])) {
$classFile = static::getAlias(self::$classMap[$className]); $classFile = self::$classMap[$className];
if (!is_file($classFile)) { if ($classFile[0] === '@') {
throw new InvalidConfigException("Class file does not exist: $classFile"); $classFile = static::getAlias($classFile);
} }
} else { } else {
// follow PSR-0 to determine the class file // follow PSR-0 to determine the class file
......
...@@ -126,8 +126,8 @@ abstract class Application extends Module ...@@ -126,8 +126,8 @@ abstract class Application extends Module
set_exception_handler(array($this, 'handleException')); set_exception_handler(array($this, 'handleException'));
set_error_handler(array($this, 'handleError'), error_reporting()); set_error_handler(array($this, 'handleError'), error_reporting());
// Allocating twice more than required to display memory exhausted error // Allocating twice more than required to display memory exhausted error
// in case of trying to allocate last 1 byte while all memory is taken. // in case of trying to allocate last 1 byte while all memory is taken. 1024 * 256 bytes
$this->_memoryReserve = str_repeat('x', 1024 * 256); $this->_memoryReserve = str_repeat('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', 1024);
register_shutdown_function(array($this, 'handleFatalError')); register_shutdown_function(array($this, 'handleFatalError'));
} }
} }
......
...@@ -167,7 +167,7 @@ class UrlManager extends Component ...@@ -167,7 +167,7 @@ class UrlManager extends Component
public function parseRequest($request) public function parseRequest($request)
{ {
if ($this->enablePrettyUrl) { if ($this->enablePrettyUrl) {
$pathInfo = $request->pathInfo; $pathInfo = $request->getPathInfo();
/** @var $rule UrlRule */ /** @var $rule UrlRule */
foreach ($this->rules as $rule) { foreach ($this->rules as $rule) {
if (($result = $rule->parseRequest($this, $request)) !== false) { if (($result = $rule->parseRequest($this, $request)) !== false) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment