From aff7c6a0ab4d3850037e39f7817c298a53c18215 Mon Sep 17 00:00:00 2001 From: rodneyrehm Date: Sat, 1 Oct 2011 18:10:48 +0000 Subject: [PATCH] - improvement replaced most in_array() calls by more efficient isset() on array_flip()ed haystacks - added notes on possible performance optimization/problem with Smarty_Security --- change_log.txt | 3 + libs/plugins/function.cycle.php | 2 +- libs/plugins/function.html_options.php | 4 +- libs/plugins/function.mailto.php | 3 +- libs/plugins/function.math.php | 11 +-- .../smarty_internal_compile_break.php | 3 +- .../smarty_internal_compile_config_load.php | 3 +- .../smarty_internal_compile_continue.php | 3 +- .../smarty_internal_compile_extends.php | 3 +- libs/sysplugins/smarty_internal_debug.php | 3 +- .../smarty_internal_templatebase.php | 38 ++++++++--- libs/sysplugins/smarty_resource.php | 5 +- libs/sysplugins/smarty_security.php | 68 ++++++++++++------- 13 files changed, 99 insertions(+), 50 deletions(-) diff --git a/change_log.txt b/change_log.txt index d0691328..3da63ccb 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,4 +1,7 @@ ===== trunk ===== +01.10.2011 +- improvement replaced most in_array() calls by more efficient isset() on array_flip()ed haystacks + 29.09.2011 - improvement of Smarty_Internal_Config::loadConfigVars() dropped the in_array for index look up diff --git a/libs/plugins/function.cycle.php b/libs/plugins/function.cycle.php index d456ee54..1778ffb5 100644 --- a/libs/plugins/function.cycle.php +++ b/libs/plugins/function.cycle.php @@ -52,7 +52,7 @@ function smarty_function_cycle($params, $template) $advance = (isset($params['advance'])) ? (bool)$params['advance'] : true; $reset = (isset($params['reset'])) ? (bool)$params['reset'] : false; - if (!in_array('values', array_keys($params))) { + if (!isset($params['values'])) { if(!isset($cycle_vars[$name]['values'])) { trigger_error("cycle: missing 'values' parameter"); return; diff --git a/libs/plugins/function.html_options.php b/libs/plugins/function.html_options.php index 269601a5..9c524b92 100644 --- a/libs/plugins/function.html_options.php +++ b/libs/plugins/function.html_options.php @@ -66,7 +66,7 @@ function smarty_function_html_options($params, $template) case 'selected': if (is_array($_val)) { - $selected = array_map('strval', array_values((array)$_val)); + $selected = array_flip(array_map('strval', array_values((array)$_val))); } else { $selected = $_val; } @@ -114,7 +114,7 @@ function smarty_function_html_options_optoutput($key, $value, $selected, $id, $c if (!is_array($value)) { $_html_result = '