mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-05 10:54:27 +02:00
- improvement replaced some strlen($foo) > 3 calls by isset($foo[3])
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
===== trunk =====
|
||||
01.10.2011
|
||||
- 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
|
||||
- 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) . '...';
|
||||
}
|
||||
} else {
|
||||
if (strlen($var) > $length) {
|
||||
if (isset($var[$length])) {
|
||||
$results = substr($var, 0, $length - 3) . '...';
|
||||
}
|
||||
}
|
||||
|
@@ -43,7 +43,7 @@ function smarty_modifier_truncate($string, $length = 80, $etc = '...', $break_wo
|
||||
}
|
||||
|
||||
// no MBString fallback
|
||||
if (strlen($string) > $length) {
|
||||
if (isset($string[$length])) {
|
||||
$length -= min($length, strlen($etc));
|
||||
if (!$break_words && !$middle) {
|
||||
$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'];
|
||||
$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);
|
||||
}
|
||||
|
||||
|
@@ -37,7 +37,7 @@ class Smarty_Internal_Compile_Private_Block_Plugin extends Smarty_Internal_Compi
|
||||
*/
|
||||
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
|
||||
// check and get attributes
|
||||
$_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)
|
||||
{
|
||||
if (strlen($tag) < 5 || substr($tag, -5) != 'close') {
|
||||
if (!isset($tag[5]) || substr($tag, -5) != 'close') {
|
||||
// opening tag of block plugin
|
||||
// check and get attributes
|
||||
$_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)
|
||||
{
|
||||
if (strlen($tag) < 6 || substr($tag,-5) != 'close') {
|
||||
if (!isset($tag[6]) || substr($tag,-5) != 'close') {
|
||||
// opening tag of block plugin
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
|
@@ -226,10 +226,10 @@ class Smarty_Internal_Utility {
|
||||
(strlen((string) $_file) > strlen($_resource_part_2) && substr_compare((string) $_file, $_resource_part_2, - strlen($_resource_part_2), strlen($_resource_part_2)) == 0))) {
|
||||
if (isset($exp_time)) {
|
||||
if (time() - @filemtime($_file) >= $exp_time) {
|
||||
$_count += @ unlink((string) $_file) ? 1 : 0;
|
||||
$_count += @unlink((string) $_file) ? 1 : 0;
|
||||
}
|
||||
} else {
|
||||
$_count += @ unlink((string) $_file) ? 1 : 0;
|
||||
$_count += @unlink((string) $_file) ? 1 : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -364,7 +364,7 @@ class Smarty_Security {
|
||||
return true;
|
||||
}
|
||||
// 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;
|
||||
}
|
||||
// bubble up one level
|
||||
@@ -412,7 +412,7 @@ class Smarty_Security {
|
||||
return true;
|
||||
}
|
||||
// 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;
|
||||
}
|
||||
// bubble up one level
|
||||
|
Reference in New Issue
Block a user