From 47f6a2999841bdca866725e3ffa28986ef59ffb5 Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 16 Nov 2010 22:24:54 -0500 Subject: [PATCH] Small optimizations in env() and Helper::_parseAttributes(). --- cake/basics.php | 4 ++-- cake/libs/view/helper.php | 9 ++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/cake/basics.php b/cake/basics.php index 602bec763..c41301ea1 100644 --- a/cake/basics.php +++ b/cake/basics.php @@ -264,14 +264,14 @@ if (!function_exists('sortByKey')) { * @link http://book.cakephp.org/view/1130/env */ function env($key) { - if ($key == 'HTTPS') { + if ($key === 'HTTPS') { if (isset($_SERVER['HTTPS'])) { return (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off'); } return (strpos(env('SCRIPT_URI'), 'https://') === 0); } - if ($key == 'SCRIPT_NAME') { + if ($key === 'SCRIPT_NAME') { if (env('CGI_MODE') && isset($_ENV['SCRIPT_URL'])) { $key = 'SCRIPT_URL'; } diff --git a/cake/libs/view/helper.php b/cake/libs/view/helper.php index 68466a25f..20e41953c 100644 --- a/cake/libs/view/helper.php +++ b/cake/libs/view/helper.php @@ -355,14 +355,13 @@ class Helper extends Object { if (!is_array($exclude)) { $exclude = array(); } - $keys = array_diff(array_keys($options), array_merge($exclude, array('escape'))); - $values = array_intersect_key(array_values($options), $keys); + $filtered = array_diff_key($options, array_merge(array_flip($exclude), array('escape' => true))); $escape = $options['escape']; $attributes = array(); - foreach ($keys as $index => $key) { - if ($values[$index] !== false && $values[$index] !== null) { - $attributes[] = $this->__formatAttribute($key, $values[$index], $escape); + foreach ($filtered as $key => $value) { + if ($value !== false && $value !== null) { + $attributes[] = $this->__formatAttribute($key, $value, $escape); } } $out = implode(' ', $attributes);