- code optimization at crc32 hash computation

This commit is contained in:
Uwe.Tews
2009-03-29 13:13:33 +00:00
parent 53e31d8162
commit 590029c092
4 changed files with 5 additions and 4 deletions

View File

@@ -90,7 +90,7 @@ class Smarty_Internal_CacheResource_File extends Smarty_Internal_PluginBase {
{ {
$_dir_sep = $this->smarty->use_sub_dirs ? DIRECTORY_SEPARATOR : '^'; $_dir_sep = $this->smarty->use_sub_dirs ? DIRECTORY_SEPARATOR : '^';
if (isset($resource_name)) { if (isset($resource_name)) {
$_resource_part = (string)sprintf("%u",crc32($resource_name)) . '.' . $resource_name . $this->smarty->php_ext; $_resource_part = (string)abs(crc32($resource_name)) . '.' . $resource_name . $this->smarty->php_ext;
} else { } else {
$_resource_part = null; $_resource_part = null;
} }
@@ -145,7 +145,7 @@ class Smarty_Internal_CacheResource_File extends Smarty_Internal_PluginBase {
private function buildCachedFilepath ($resource_name, $cache_id, $compile_id) private function buildCachedFilepath ($resource_name, $cache_id, $compile_id)
{ {
// $_filepath = md5($resource_name); // $_filepath = md5($resource_name);
$_filepath = (string)sprintf("%u",crc32($resource_name)); $_filepath = (string)abs(crc32($resource_name));
// if use_sub_dirs, break file into directories // if use_sub_dirs, break file into directories
if ($this->smarty->use_sub_dirs) { if ($this->smarty->use_sub_dirs) {
$_filepath = substr($_filepath, 0, 2) . DIRECTORY_SEPARATOR $_filepath = substr($_filepath, 0, 2) . DIRECTORY_SEPARATOR

View File

@@ -127,7 +127,7 @@ class Smarty_Internal_Resource_Extend extends Smarty_Internal_Base {
{ {
$_files = explode('|', $_template->resource_name); $_files = explode('|', $_template->resource_name);
// $_filepath = md5($_files[0]); // $_filepath = md5($_files[0]);
$_filepath = (string)sprintf("%u",crc32($_files[0])); $_filepath = (string)abs(crc32($_files[0]));
// if use_sub_dirs, break file into directories // if use_sub_dirs, break file into directories
if ($_template->smarty->use_sub_dirs) { if ($_template->smarty->use_sub_dirs) {
$_filepath = substr($_filepath, 0, 3) . DIRECTORY_SEPARATOR $_filepath = substr($_filepath, 0, 3) . DIRECTORY_SEPARATOR

View File

@@ -93,7 +93,7 @@ class Smarty_Internal_Resource_File extends Smarty_Internal_Base {
public function getCompiledFilepath($_template) public function getCompiledFilepath($_template)
{ {
// $_filepath = md5($_template->resource_name); // $_filepath = md5($_template->resource_name);
$_filepath = (string)sprintf("%u",crc32($_template->resource_name)); $_filepath = (string)abs(crc32($_template->resource_name));
// if use_sub_dirs, break file into directories // if use_sub_dirs, break file into directories
if ($_template->smarty->use_sub_dirs) { if ($_template->smarty->use_sub_dirs) {
$_filepath = substr($_filepath, 0, 3) . DIRECTORY_SEPARATOR $_filepath = substr($_filepath, 0, 3) . DIRECTORY_SEPARATOR

View File

@@ -44,6 +44,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase {
public $mustCompile = null; public $mustCompile = null;
public $suppressHeader = false; public $suppressHeader = false;
public $extract_code = false; public $extract_code = false;
public $extracted_compiled_code = '';
// Rendered content // Rendered content
public $rendered_content = null; public $rendered_content = null;
// Cache file // Cache file