mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 18:34:27 +02:00
- improve autoloader speed
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
24.10.2015
|
24.10.2015
|
||||||
- new extension handler to load functions when called
|
- new extension handler to load functions when called
|
||||||
- improve recovery from ivalid compiled template code
|
- improve recovery from ivalid compiled template code
|
||||||
|
- improve autoloader speed
|
||||||
|
|
||||||
21.10.2015
|
21.10.2015
|
||||||
- move some code into runtime extensions
|
- move some code into runtime extensions
|
||||||
|
@@ -73,8 +73,8 @@ class Smarty_Autoloader
|
|||||||
public static function register($prepend = false)
|
public static function register($prepend = false)
|
||||||
{
|
{
|
||||||
self::$SMARTY_DIR = defined('SMARTY_DIR') ? SMARTY_DIR : dirname(__FILE__) . DIRECTORY_SEPARATOR;
|
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 .
|
self::$SMARTY_SYSPLUGINS_DIR = defined('SMARTY_SYSPLUGINS_DIR') ? SMARTY_SYSPLUGINS_DIR :
|
||||||
'sysplugins' . DIRECTORY_SEPARATOR;
|
self::$SMARTY_DIR . 'sysplugins' . DIRECTORY_SEPARATOR;
|
||||||
if (version_compare(phpversion(), '5.3.0', '>=')) {
|
if (version_compare(phpversion(), '5.3.0', '>=')) {
|
||||||
spl_autoload_register(array(__CLASS__, 'autoload'), true, $prepend);
|
spl_autoload_register(array(__CLASS__, 'autoload'), true, $prepend);
|
||||||
} else {
|
} else {
|
||||||
@@ -90,22 +90,23 @@ class Smarty_Autoloader
|
|||||||
public static function autoload($class)
|
public static function autoload($class)
|
||||||
{
|
{
|
||||||
$_class = strtolower($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';
|
||||||
$file = self::$SMARTY_SYSPLUGINS_DIR . $_class . '.php';
|
if (strpos($_class, 'smarty_internal_') === 0) {
|
||||||
if (!empty($match[3])) {
|
if (strpos($_class, 'smarty_internal_compile_') === 0) {
|
||||||
if (!empty($match[4])) {
|
if (is_file($file)) {
|
||||||
if (is_file($file)) {
|
require $file;
|
||||||
require $file;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
@include $file;
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
} 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;
|
@include $file;
|
||||||
return;
|
return;
|
||||||
} elseif (!empty($match[11]) && isset(self::$rootClasses[$_class])) {
|
} elseif (!empty($match[9]) && isset(self::$rootClasses[$_class])) {
|
||||||
$file = self::$rootClasses[$_class];
|
$file = self::$rootClasses[$_class];
|
||||||
require $file;
|
require $file;
|
||||||
return;
|
return;
|
||||||
@@ -114,7 +115,6 @@ class Smarty_Autoloader
|
|||||||
if (0 !== strpos($_class, 'smarty')) {
|
if (0 !== strpos($_class, 'smarty')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$file = isset($file) ? $file : self::$SMARTY_SYSPLUGINS_DIR . $_class . '.php';
|
|
||||||
if (is_file($file)) {
|
if (is_file($file)) {
|
||||||
require $file;
|
require $file;
|
||||||
return;
|
return;
|
||||||
|
@@ -120,7 +120,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
/**
|
/**
|
||||||
* smarty version
|
* smarty version
|
||||||
*/
|
*/
|
||||||
const SMARTY_VERSION = '3.1.28-dev/70';
|
const SMARTY_VERSION = '3.1.28-dev/71';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* define variable scopes
|
* define variable scopes
|
||||||
|
Reference in New Issue
Block a user