diff --git a/change_log.txt b/change_log.txt index c48df6c8..af215e85 100644 --- a/change_log.txt +++ b/change_log.txt @@ -2,6 +2,7 @@ 24.10.2015 - new extension handler to load functions when called - improve recovery from ivalid compiled template code + - improve autoloader speed 21.10.2015 - move some code into runtime extensions diff --git a/libs/Autoloader.php b/libs/Autoloader.php index ed4084c6..7d0c388a 100644 --- a/libs/Autoloader.php +++ b/libs/Autoloader.php @@ -73,8 +73,8 @@ class Smarty_Autoloader public static function register($prepend = false) { self::$SMARTY_DIR = defined('SMARTY_DIR') ? SMARTY_DIR : dirname(__FILE__) . DIRECTORY_SEPARATOR; - self::$SMARTY_SYSPLUGINS_DIR = defined('SMARTY_SYSPLUGINS_DIR') ? SMARTY_SYSPLUGINS_DIR : self::$SMARTY_DIR . - 'sysplugins' . DIRECTORY_SEPARATOR; + self::$SMARTY_SYSPLUGINS_DIR = defined('SMARTY_SYSPLUGINS_DIR') ? SMARTY_SYSPLUGINS_DIR : + self::$SMARTY_DIR . 'sysplugins' . DIRECTORY_SEPARATOR; if (version_compare(phpversion(), '5.3.0', '>=')) { spl_autoload_register(array(__CLASS__, 'autoload'), true, $prepend); } else { @@ -90,22 +90,23 @@ class Smarty_Autoloader public static function autoload($class) { $_class = strtolower($class); - if (preg_match('/^(smarty_((internal_(compile_)?)|((template_(source|config|cache|compiled|resource_base))|((cached|compiled)?resource)|(variable|security)))|(smarty(bc)?)$)/', $_class, $match)) { - $file = self::$SMARTY_SYSPLUGINS_DIR . $_class . '.php'; - if (!empty($match[3])) { - if (!empty($match[4])) { - if (is_file($file)) { - require $file; - } - return; - } else { - @include $file; - return; + $file = self::$SMARTY_SYSPLUGINS_DIR . $_class . '.php'; + if (strpos($_class, 'smarty_internal_') === 0) { + if (strpos($_class, 'smarty_internal_compile_') === 0) { + if (is_file($file)) { + require $file; } - } elseif (!empty($match[5])) { + return; + } + @include $file; + return; + } + if (preg_match('/^(smarty_(((template_(source|config|cache|compiled|resource_base))|((cached|compiled)?resource)|(variable|security)))|(smarty(bc)?)$)/', + $_class, $match)) { + if (!empty($match[3])) { @include $file; return; - } elseif (!empty($match[11]) && isset(self::$rootClasses[$_class])) { + } elseif (!empty($match[9]) && isset(self::$rootClasses[$_class])) { $file = self::$rootClasses[$_class]; require $file; return; @@ -114,7 +115,6 @@ class Smarty_Autoloader if (0 !== strpos($_class, 'smarty')) { return; } - $file = isset($file) ? $file : self::$SMARTY_SYSPLUGINS_DIR . $_class . '.php'; if (is_file($file)) { require $file; return; diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index b23220c9..9eac6ef8 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -120,7 +120,7 @@ class Smarty extends Smarty_Internal_TemplateBase /** * smarty version */ - const SMARTY_VERSION = '3.1.28-dev/70'; + const SMARTY_VERSION = '3.1.28-dev/71'; /** * define variable scopes