diff options
author | Meik Sievertsen <acydburn@phpbb.com> | 2008-12-02 16:27:44 +0000 |
---|---|---|
committer | Meik Sievertsen <acydburn@phpbb.com> | 2008-12-02 16:27:44 +0000 |
commit | eddddaa3a4cdf69b51f9fccf0742c8add94016b6 (patch) | |
tree | 79822bdf8e9f67d02f16a8183ebc2e282323a8ff /phpBB/includes | |
parent | d054940739057c1b86c3f5137412910869c3e763 (diff) | |
download | forums-eddddaa3a4cdf69b51f9fccf0742c8add94016b6.tar forums-eddddaa3a4cdf69b51f9fccf0742c8add94016b6.tar.gz forums-eddddaa3a4cdf69b51f9fccf0742c8add94016b6.tar.bz2 forums-eddddaa3a4cdf69b51f9fccf0742c8add94016b6.tar.xz forums-eddddaa3a4cdf69b51f9fccf0742c8add94016b6.zip |
Slight performance increase for common parameter calls to append_sid() (Bug #37555 - Patch by BartVB)
Unsure if this works with the mysterious, uncommented block in front of it, the parsed_urls thingy... whoever wrote it, please prod me. :) Or add comments.
git-svn-id: file:///svn/phpbb/trunk@9151 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes')
-rw-r--r-- | phpBB/includes/functions.php | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 9ba6e9a367..b5c9284c15 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2154,30 +2154,45 @@ function append_sid($url, $params = false, $is_amp = true, $session_id = false) } } - // Assign sid if session id is not specified - if ($session_id === false) - { - $session_id = $_SID; - } - - $amp_delim = ($is_amp) ? '&' : '&'; - $url_delim = (strpos($url, '?') === false) ? '?' : $amp_delim; - - // Appending custom url parameter? - $append_url = (!empty($_EXTRA_URL)) ? implode($amp_delim, $_EXTRA_URL) : ''; + $params_is_array = is_array($params); + // Get anchor $anchor = ''; if (strpos($url, '#') !== false) { list($url, $anchor) = explode('#', $url, 2); $anchor = '#' . $anchor; } - else if (!is_array($params) && strpos($params, '#') !== false) + else if (!$params_is_array && strpos($params, '#') !== false) { list($params, $anchor) = explode('#', $params, 2); $anchor = '#' . $anchor; } + // Handle really simple cases quickly + if ($_SID == '' && $session_id === false && empty($_EXTRA_URL) && !$params_is_array && !$anchor) + { + if ($params === false) + { + return $url; + } + + $url_delim = (strpos($url, '?') === false) ? '?' : (($is_amp) ? '&' : '&'); + return $url . ($params !== false ? $url_delim. $params : ''); + } + + // Assign sid if session id is not specified + if ($session_id === false) + { + $session_id = $_SID; + } + + $amp_delim = ($is_amp) ? '&' : '&'; + $url_delim = (strpos($url, '?') === false) ? '?' : $amp_delim; + + // Appending custom url parameter? + $append_url = (!empty($_EXTRA_URL)) ? implode($amp_delim, $_EXTRA_URL) : ''; + // Use the short variant if possible ;) if ($params === false) { |