diff --git a/change_log.txt b/change_log.txt index 2f0ce027..aeac846d 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,4 +1,7 @@  ===== 3.1.25-dev===== (xx.xx.2015) + 15.06.2015 + - optimization of smarty_cachereource_keyvaluestore.php code + 14.06.2015 - bugfix a relative sub template path could fail if template_dir path did contain /../ https://github.com/smarty-php/smarty/issues/50 - optimization rework of path normalization diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index 564afdc0..f32c6bd2 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -111,7 +111,7 @@ class Smarty extends Smarty_Internal_TemplateBase /** * smarty version */ - const SMARTY_VERSION = '3.1.25-dev/8'; + const SMARTY_VERSION = '3.1.25-dev/9'; /** * define variable scopes diff --git a/libs/sysplugins/smarty_cacheresource_keyvaluestore.php b/libs/sysplugins/smarty_cacheresource_keyvaluestore.php index 507608e4..2fdc7e42 100644 --- a/libs/sysplugins/smarty_cacheresource_keyvaluestore.php +++ b/libs/sysplugins/smarty_cacheresource_keyvaluestore.php @@ -36,6 +36,7 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource * @var array */ protected $contents = array(); + /** * cache for timestamps * @@ -53,10 +54,7 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource */ public function populate(Smarty_Template_Cached $cached, Smarty_Internal_Template $_template) { - $cached->filepath = $_template->source->uid - . '#' . $this->sanitize($cached->source->resource) - . '#' . $this->sanitize($cached->cache_id) - . '#' . $this->sanitize($cached->compile_id); + $cached->filepath = $_template->source->uid . '#' . $this->sanitize($cached->source->resource) . '#' . $this->sanitize($cached->cache_id) . '#' . $this->sanitize($cached->compile_id); $this->populateTimestamp($cached); } @@ -136,7 +134,7 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource public function readCachedContent(Smarty_Internal_Template $_template) { $content = $_template->cached->content ? $_template->cached->content : null; - $timestamp = null; + $timestamp = null; if ($content === null) { if (!$this->fetch($_template->cached->filepath, $_template->source->name, $_template->cache_id, $_template->compile_id, $content, $timestamp, $_template->source->uid)) { return false; @@ -148,7 +146,6 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource return false; } - /** * Empty cache * {@internal the $exp_time argument is ignored altogether }} @@ -298,11 +295,8 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource */ protected function getMetaTimestamp(&$content) { - $s = unpack("N", $content[0] . $content[1] . $content[2] . $content[3]); - $m = unpack("N", $content[4] . $content[5] . $content[6] . $content[7]); - $content = substr($content, 8); - - return $s[1] + ($m[1] / 100000000); + extract(unpack('N1s/N1m/a*content', $content)); + return $s + ($m / 100000000); } /**