Permalink
Browse files

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
  • Loading branch information...
1 parent e1d6c46 commit 66cb413bc614bfe50d02059347a0ad0351a014c2 @vlakoff vlakoff committed Dec 3, 2012
Showing with 10 additions and 7 deletions.
  1. +10 −7 system/core/Config.php
@@ -245,15 +245,18 @@ public function site_url($uri = '')
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;

0 comments on commit 66cb413

Please sign in to comment.