mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-05 10:54:27 +02:00
- optimization of resource class loading
This commit is contained in:
@@ -21,7 +21,7 @@ abstract class Smarty_CacheResource
|
|||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected static $sysplugins = array(
|
protected static $sysplugins = array(
|
||||||
'file' => true,
|
'file' => 'smarty_internal_cacheresource_file.php',
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -116,7 +116,7 @@ abstract class Smarty_CacheResource
|
|||||||
// theoretically locking_timeout should be checked against time_limit (max_execution_time)
|
// theoretically locking_timeout should be checked against time_limit (max_execution_time)
|
||||||
$start = microtime(true);
|
$start = microtime(true);
|
||||||
$hadLock = null;
|
$hadLock = null;
|
||||||
while ($this->hasLock($smarty, $cached)) {
|
while ($r = $this->hasLock($smarty, $cached)) {
|
||||||
$hadLock = true;
|
$hadLock = true;
|
||||||
if (microtime(true) - $start > $smarty->locking_timeout) {
|
if (microtime(true) - $start > $smarty->locking_timeout) {
|
||||||
// abort waiting for lock release
|
// abort waiting for lock release
|
||||||
@@ -198,6 +198,9 @@ abstract class Smarty_CacheResource
|
|||||||
// try sysplugins dir
|
// try sysplugins dir
|
||||||
if (isset(self::$sysplugins[$type])) {
|
if (isset(self::$sysplugins[$type])) {
|
||||||
$cache_resource_class = 'Smarty_Internal_CacheResource_' . ucfirst($type);
|
$cache_resource_class = 'Smarty_Internal_CacheResource_' . ucfirst($type);
|
||||||
|
if (!class_exists($cache_resource_class, false)) {
|
||||||
|
require SMARTY_SYSPLUGINS_DIR . self::$sysplugins[$type];
|
||||||
|
}
|
||||||
return $smarty->_cacheresource_handlers[$type] = new $cache_resource_class();
|
return $smarty->_cacheresource_handlers[$type] = new $cache_resource_class();
|
||||||
}
|
}
|
||||||
// try plugins dir
|
// try plugins dir
|
||||||
|
@@ -53,12 +53,12 @@ abstract class Smarty_Resource
|
|||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected static $sysplugins = array(
|
protected static $sysplugins = array(
|
||||||
'file' => true,
|
'file' => 'smarty_internal_resource_file.php',
|
||||||
'string' => true,
|
'string' => 'smarty_internal_resource_string.php',
|
||||||
'extends' => true,
|
'extends' => 'smarty_internal_resource_extends.php',
|
||||||
'stream' => true,
|
'stream' => 'smarty_internal_resource_stream.php',
|
||||||
'eval' => true,
|
'eval' => 'smarty_internal_resource_eval.php',
|
||||||
'php' => true
|
'php' => 'smarty_internal_resource_php.php'
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -171,6 +171,9 @@ abstract class Smarty_Resource
|
|||||||
// try sysplugins dir
|
// try sysplugins dir
|
||||||
if (isset(self::$sysplugins[$type])) {
|
if (isset(self::$sysplugins[$type])) {
|
||||||
$_resource_class = 'Smarty_Internal_Resource_' . ucfirst($type);
|
$_resource_class = 'Smarty_Internal_Resource_' . ucfirst($type);
|
||||||
|
if (!class_exists($_resource_class, false)) {
|
||||||
|
require SMARTY_SYSPLUGINS_DIR . self::$sysplugins[$type];
|
||||||
|
}
|
||||||
return $smarty->_resource_handlers[$type] = new $_resource_class();
|
return $smarty->_resource_handlers[$type] = new $_resource_class();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user