From 66cb413bc614bfe50d02059347a0ad0351a014c2 Mon Sep 17 00:00:00 2001 From: vlakoff Date: Mon, 3 Dec 2012 10:43:44 +0100 Subject: config->site_url() optimizations - direct access to config array, instead of item() calls - the string cast is just in case 'url_suffix' would be set to false or null; the function produces the same results without this cast, but it leads to a robuster code, as false and null are sanitized and skip the suffix insertion code - altered conditional structure: if no suffix, skip the appending of an empty string to $uri --- system/core/Config.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index 8250b5b1a..9e6d2cbf2 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -245,15 +245,18 @@ class CI_Config { if ($this->item('enable_query_strings') === FALSE) { - $suffix = ($this->item('url_suffix') === FALSE) ? '' : $this->item('url_suffix'); + $suffix = isset($this->config['url_suffix']) ? (string) $this->config['url_suffix'] : ''; - if ($suffix !== '' && ($offset = strpos($uri, '?')) !== FALSE) + if ($suffix !== '') { - $uri = substr($uri, 0, $offset).$suffix.substr($uri, $offset); - } - else - { - $uri .= $suffix; + if (($offset = strpos($uri, '?')) !== FALSE) + { + $uri = substr($uri, 0, $offset).$suffix.substr($uri, $offset); + } + else + { + $uri .= $suffix; + } } return $this->slash_item('base_url').$this->slash_item('index_page').$uri; -- cgit v1.2.3-24-g4f1b From 4d9fd19e6e224042e04f71c35b174990a177527d Mon Sep 17 00:00:00 2001 From: vlakoff Date: Mon, 3 Dec 2012 11:31:00 +0100 Subject: config->site_url(): remove useless cast thanks to narfbg --- system/core/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index 9e6d2cbf2..38bcd5c8f 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -245,7 +245,7 @@ class CI_Config { if ($this->item('enable_query_strings') === FALSE) { - $suffix = isset($this->config['url_suffix']) ? (string) $this->config['url_suffix'] : ''; + $suffix = isset($this->config['url_suffix']) ? $this->config['url_suffix'] : ''; if ($suffix !== '') { -- cgit v1.2.3-24-g4f1b