- optimization replace hhvm extension by inline code

This commit is contained in:
uwetews
2015-12-25 10:02:10 +01:00
parent fdd20dd4f1
commit 613e66c257
6 changed files with 4 additions and 34 deletions

View File

@@ -1,6 +1,7 @@
 ===== 3.1.30-dev ===== (xx.xx.xx)  ===== 3.1.30-dev ===== (xx.xx.xx)
25.12.2015 25.12.2015
- compile {block} tag code and its processing into classes - compile {block} tag code and its processing into classes
- optimization replace hhvm extension by inline code
24.12.2015 24.12.2015
- new feature Compiler does now observe the template_dir setting and will create separate compiled files if required - new feature Compiler does now observe the template_dir setting and will create separate compiled files if required

View File

@@ -98,7 +98,8 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
$_smarty_tpl = $_template; $_smarty_tpl = $_template;
$_template->cached->valid = false; $_template->cached->valid = false;
if ($update && defined('HHVM_VERSION')) { if ($update && defined('HHVM_VERSION')) {
return $_template->smarty->ext->_hhvm->includeHhvm($_template, $_template->cached->filepath); eval("?>" . file_get_contents($_template->cached->filepath));
return true;
} else { } else {
return @include $_template->cached->filepath; return @include $_template->cached->filepath;
} }

View File

@@ -14,7 +14,6 @@
* @property Smarty_Internal_Runtime_TplFunction $_tplFunction * @property Smarty_Internal_Runtime_TplFunction $_tplFunction
* @property Smarty_Internal_Runtime_Var $_var * @property Smarty_Internal_Runtime_Var $_var
* @property Smarty_Internal_Runtime_Foreach $_foreach * @property Smarty_Internal_Runtime_Foreach $_foreach
* @property Smarty_Internal_Runtime_Hhvm $_hhvm
* @property Smarty_Internal_Runtime_WriteFile $_writeFile * @property Smarty_Internal_Runtime_WriteFile $_writeFile
* @property Smarty_Internal_Runtime_CodeFrame $_codeFrame * @property Smarty_Internal_Runtime_CodeFrame $_codeFrame
* @property Smarty_Internal_Runtime_FilterHandler $_filterHandler * @property Smarty_Internal_Runtime_FilterHandler $_filterHandler

View File

@@ -1,30 +0,0 @@
<?php
/**
* Runtime Extension Hhvm
*
* include patch for modified compiled or cached templates
* HHVM does not check if file was modified when including same file multiple times
*
* @package Smarty
* @subpackage PluginsInternal
* @author Uwe Tews
*/
class Smarty_Internal_Runtime_Hhvm
{
/**
* @param \Smarty_Internal_Template $_template
* @param string $file file name
*
* @return mixed
*/
static function includeHhvm(Smarty_Internal_Template $_template, $file)
{
$_smarty_tpl = $_template;
$tmp_file = $file . preg_replace('![^\w]+!', '_', uniqid(rand(), true)) . '.php';
file_put_contents($tmp_file, file_get_contents($file));
$result = @include $tmp_file;
@unlink($tmp_file);
return $result;
}
}

View File

@@ -475,7 +475,6 @@ class Smarty_Internal_TestInstall
'smarty_internal_runtime_filterhandler.php' => true, 'smarty_internal_runtime_filterhandler.php' => true,
'smarty_internal_runtime_foreach.php' => true, 'smarty_internal_runtime_foreach.php' => true,
'smarty_internal_runtime_getincludepath.php' => true, 'smarty_internal_runtime_getincludepath.php' => true,
'smarty_internal_runtime_hhvm.php' => true,
'smarty_internal_runtime_inheritance.php' => true, 'smarty_internal_runtime_inheritance.php' => true,
'smarty_internal_runtime_tplfunction.php' => true, 'smarty_internal_runtime_tplfunction.php' => true,
'smarty_internal_runtime_updatecache.php' => true, 'smarty_internal_runtime_updatecache.php' => true,

View File

@@ -169,7 +169,7 @@ class Smarty_Template_Compiled extends Smarty_Template_Resource_Base
} }
$_smarty_tpl = $_template; $_smarty_tpl = $_template;
if (defined('HHVM_VERSION')) { if (defined('HHVM_VERSION')) {
$_template->smarty->ext->_hhvm->includeHhvm($_template, $_template->compiled->filepath); eval("?>" . file_get_contents($_template->compiled->filepath));
} else { } else {
include($_template->compiled->filepath); include($_template->compiled->filepath);
} }