mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-06 11:24:27 +02:00
- improvement replaced some strlen($foo) > 3 calls by isset($foo[3])
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
===== trunk =====
|
===== trunk =====
|
||||||
01.10.2011
|
01.10.2011
|
||||||
- improvement replaced most in_array() calls by more efficient isset() on array_flip()ed haystacks
|
- improvement replaced most in_array() calls by more efficient isset() on array_flip()ed haystacks
|
||||||
|
- improvement replaced some strlen($foo) > 3 calls by isset($foo[3])
|
||||||
|
|
||||||
29.09.2011
|
29.09.2011
|
||||||
- improvement of Smarty_Internal_Config::loadConfigVars() dropped the in_array for index look up
|
- improvement of Smarty_Internal_Config::loadConfigVars() dropped the in_array for index look up
|
||||||
|
@@ -75,7 +75,7 @@ function smarty_modifier_debug_print_var ($var, $depth = 0, $length = 40)
|
|||||||
$results = mb_substr($var, 0, $length - 3, SMARTY_RESOURCE_CHAR_SET) . '...';
|
$results = mb_substr($var, 0, $length - 3, SMARTY_RESOURCE_CHAR_SET) . '...';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (strlen($var) > $length) {
|
if (isset($var[$length])) {
|
||||||
$results = substr($var, 0, $length - 3) . '...';
|
$results = substr($var, 0, $length - 3) . '...';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -43,7 +43,7 @@ function smarty_modifier_truncate($string, $length = 80, $etc = '...', $break_wo
|
|||||||
}
|
}
|
||||||
|
|
||||||
// no MBString fallback
|
// no MBString fallback
|
||||||
if (strlen($string) > $length) {
|
if (isset($string[$length])) {
|
||||||
$length -= min($length, strlen($etc));
|
$length -= min($length, strlen($etc));
|
||||||
if (!$break_words && !$middle) {
|
if (!$break_words && !$middle) {
|
||||||
$string = preg_replace('/\s+?(\S+)?$/', '', substr($string, 0, $length + 1));
|
$string = preg_replace('/\s+?(\S+)?$/', '', substr($string, 0, $length + 1));
|
||||||
|
@@ -54,7 +54,7 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_CompileBase {
|
|||||||
|
|
||||||
$from = $_attr['from'];
|
$from = $_attr['from'];
|
||||||
$item = $_attr['item'];
|
$item = $_attr['item'];
|
||||||
if (substr_compare("\$_smarty_tpl->tpl_vars[$item]", $from,0, strlen("\$_smarty_tpl->tpl_vars[$item]")) == 0) {
|
if (!strncmp("\$_smarty_tpl->tpl_vars[$item]", $from, strlen($item) + 24)) {
|
||||||
$compiler->trigger_template_error("item variable {$item} may not be the same variable as at 'from'", $compiler->lex->taglineno);
|
$compiler->trigger_template_error("item variable {$item} may not be the same variable as at 'from'", $compiler->lex->taglineno);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -37,7 +37,7 @@ class Smarty_Internal_Compile_Private_Block_Plugin extends Smarty_Internal_Compi
|
|||||||
*/
|
*/
|
||||||
public function compile($args, $compiler, $parameter, $tag, $function)
|
public function compile($args, $compiler, $parameter, $tag, $function)
|
||||||
{
|
{
|
||||||
if (strlen($tag) < 6 || substr($tag, -5) != 'close') {
|
if (!isset($tag[6]) || substr($tag, -5) != 'close') {
|
||||||
// opening tag of block plugin
|
// opening tag of block plugin
|
||||||
// check and get attributes
|
// check and get attributes
|
||||||
$_attr = $this->getAttributes($compiler, $args);
|
$_attr = $this->getAttributes($compiler, $args);
|
||||||
|
@@ -37,7 +37,7 @@ class Smarty_Internal_Compile_Private_Object_Block_Function extends Smarty_Inter
|
|||||||
*/
|
*/
|
||||||
public function compile($args, $compiler, $parameter, $tag, $method)
|
public function compile($args, $compiler, $parameter, $tag, $method)
|
||||||
{
|
{
|
||||||
if (strlen($tag) < 5 || substr($tag, -5) != 'close') {
|
if (!isset($tag[5]) || substr($tag, -5) != 'close') {
|
||||||
// opening tag of block plugin
|
// opening tag of block plugin
|
||||||
// check and get attributes
|
// check and get attributes
|
||||||
$_attr = $this->getAttributes($compiler, $args);
|
$_attr = $this->getAttributes($compiler, $args);
|
||||||
|
@@ -36,7 +36,7 @@ class Smarty_Internal_Compile_Private_Registered_Block extends Smarty_Internal_C
|
|||||||
*/
|
*/
|
||||||
public function compile($args, $compiler, $parameter, $tag)
|
public function compile($args, $compiler, $parameter, $tag)
|
||||||
{
|
{
|
||||||
if (strlen($tag) < 6 || substr($tag,-5) != 'close') {
|
if (!isset($tag[6]) || substr($tag,-5) != 'close') {
|
||||||
// opening tag of block plugin
|
// opening tag of block plugin
|
||||||
// check and get attributes
|
// check and get attributes
|
||||||
$_attr = $this->getAttributes($compiler, $args);
|
$_attr = $this->getAttributes($compiler, $args);
|
||||||
|
@@ -364,7 +364,7 @@ class Smarty_Security {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// abort if we've reached root
|
// abort if we've reached root
|
||||||
if (($pos = strrpos($directory, DS)) === false || strlen($directory) < 2) {
|
if (($pos = strrpos($directory, DS)) === false || !isset($directory[2])) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// bubble up one level
|
// bubble up one level
|
||||||
@@ -412,7 +412,7 @@ class Smarty_Security {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// abort if we've reached root
|
// abort if we've reached root
|
||||||
if (($pos = strrpos($directory, DS)) === false || strlen($directory) < 2) {
|
if (($pos = strrpos($directory, DS)) === false || !isset($directory[2])) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// bubble up one level
|
// bubble up one level
|
||||||
|
Reference in New Issue
Block a user