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
}
spl_autoload_register(array('Yii', 'autoload'));
Yii::$classMap = include(__DIR__ . '/classes.php');
......@@ -337,9 +337,9 @@ class YiiBase
$className = ltrim($className, '\\');
if (isset(self::$classMap[$className])) {
$classFile = static::getAlias(self::$classMap[$className]);
if (!is_file($classFile)) {
throw new InvalidConfigException("Class file does not exist: $classFile");
$classFile = self::$classMap[$className];
if ($classFile[0] === '@') {
$classFile = static::getAlias($classFile);
}
} else {
// follow PSR-0 to determine the class file
......
......@@ -126,8 +126,8 @@ abstract class Application extends Module
set_exception_handler(array($this, 'handleException'));
set_error_handler(array($this, 'handleError'), error_reporting());
// Allocating twice more than required to display memory exhausted error
// in case of trying to allocate last 1 byte while all memory is taken.
$this->_memoryReserve = str_repeat('x', 1024 * 256);
// in case of trying to allocate last 1 byte while all memory is taken. 1024 * 256 bytes
$this->_memoryReserve = str_repeat('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', 1024);
register_shutdown_function(array($this, 'handleFatalError'));
}
}
......
......@@ -167,7 +167,7 @@ class UrlManager extends Component
public function parseRequest($request)
{
if ($this->enablePrettyUrl) {
$pathInfo = $request->pathInfo;
$pathInfo = $request->getPathInfo();
/** @var $rule UrlRule */
foreach ($this->rules as $rule) {
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