summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--change_log.txt1
-rw-r--r--libs/plugins/modifier.debug_print_var.php2
-rw-r--r--libs/plugins/modifier.truncate.php2
-rw-r--r--libs/sysplugins/smarty_internal_compile_foreach.php2
-rw-r--r--libs/sysplugins/smarty_internal_compile_private_block_plugin.php2
-rw-r--r--libs/sysplugins/smarty_internal_compile_private_object_block_function.php2
-rw-r--r--libs/sysplugins/smarty_internal_compile_private_registered_block.php2
-rw-r--r--libs/sysplugins/smarty_internal_utility.php4
-rw-r--r--libs/sysplugins/smarty_security.php4
9 files changed, 11 insertions, 10 deletions
diff --git a/change_log.txt b/change_log.txt
index 3da63ccb..d1b0c273 100644
--- a/change_log.txt
+++ b/change_log.txt
@@ -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
diff --git a/libs/plugins/modifier.debug_print_var.php b/libs/plugins/modifier.debug_print_var.php
index bac589c1..747c87fd 100644
--- a/libs/plugins/modifier.debug_print_var.php
+++ b/libs/plugins/modifier.debug_print_var.php
@@ -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) . '...';
}
}
diff --git a/libs/plugins/modifier.truncate.php b/libs/plugins/modifier.truncate.php
index f495bb22..99ae5437 100644
--- a/libs/plugins/modifier.truncate.php
+++ b/libs/plugins/modifier.truncate.php
@@ -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));
diff --git a/libs/sysplugins/smarty_internal_compile_foreach.php b/libs/sysplugins/smarty_internal_compile_foreach.php
index 33bd886a..1354c89d 100644
--- a/libs/sysplugins/smarty_internal_compile_foreach.php
+++ b/libs/sysplugins/smarty_internal_compile_foreach.php
@@ -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);
}
diff --git a/libs/sysplugins/smarty_internal_compile_private_block_plugin.php b/libs/sysplugins/smarty_internal_compile_private_block_plugin.php
index 00fdd19f..13a1c088 100644
--- a/libs/sysplugins/smarty_internal_compile_private_block_plugin.php
+++ b/libs/sysplugins/smarty_internal_compile_private_block_plugin.php
@@ -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);
diff --git a/libs/sysplugins/smarty_internal_compile_private_object_block_function.php b/libs/sysplugins/smarty_internal_compile_private_object_block_function.php
index 603195cb..cca924d1 100644
--- a/libs/sysplugins/smarty_internal_compile_private_object_block_function.php
+++ b/libs/sysplugins/smarty_internal_compile_private_object_block_function.php
@@ -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);
diff --git a/libs/sysplugins/smarty_internal_compile_private_registered_block.php b/libs/sysplugins/smarty_internal_compile_private_registered_block.php
index b1ff4cb8..f7dd74ba 100644
--- a/libs/sysplugins/smarty_internal_compile_private_registered_block.php
+++ b/libs/sysplugins/smarty_internal_compile_private_registered_block.php
@@ -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);
diff --git a/libs/sysplugins/smarty_internal_utility.php b/libs/sysplugins/smarty_internal_utility.php
index 184ddea5..7138e96c 100644
--- a/libs/sysplugins/smarty_internal_utility.php
+++ b/libs/sysplugins/smarty_internal_utility.php
@@ -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;
}
}
}
diff --git a/libs/sysplugins/smarty_security.php b/libs/sysplugins/smarty_security.php
index 9f80ca95..6ed96204 100644
--- a/libs/sysplugins/smarty_security.php
+++ b/libs/sysplugins/smarty_security.php
@@ -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