Optimize get_instance() calls/assignments
diff --git a/system/helpers/cookie_helper.php b/system/helpers/cookie_helper.php
index e465412..5cdcdd1 100644
--- a/system/helpers/cookie_helper.php
+++ b/system/helpers/cookie_helper.php
@@ -59,8 +59,7 @@
function set_cookie($name, $value = '', $expire = '', $domain = '', $path = '/', $prefix = '', $secure = FALSE, $httponly = FALSE)
{
// Set the config file options
- $CI =& get_instance();
- $CI->input->set_cookie($name, $value, $expire, $domain, $path, $prefix, $secure, $httponly);
+ get_instance()->input->set_cookie($name, $value, $expire, $domain, $path, $prefix, $secure, $httponly);
}
}
@@ -77,9 +76,8 @@
*/
function get_cookie($index, $xss_clean = FALSE)
{
- $CI =& get_instance();
$prefix = isset($_COOKIE[$index]) ? '' : config_item('cookie_prefix');
- return $CI->input->cookie($prefix.$index, $xss_clean);
+ return get_instance()->input->cookie($prefix.$index, $xss_clean);
}
}
diff --git a/system/helpers/html_helper.php b/system/helpers/html_helper.php
index ece3958..988eee7 100644
--- a/system/helpers/html_helper.php
+++ b/system/helpers/html_helper.php
@@ -199,15 +199,13 @@
{
if ($k === 'src' && strpos($v, '://') === FALSE)
{
- $CI =& get_instance();
-
if ($index_page === TRUE)
{
- $img .= ' src="'.$CI->config->site_url($v).'"';
+ $img .= ' src="'.get_instance()->config->site_url($v).'"';
}
else
{
- $img .= ' src="'.$CI->config->slash_item('base_url').$v.'"';
+ $img .= ' src="'.get_instance()->config->slash_item('base_url').$v.'"';
}
}
else
diff --git a/system/helpers/language_helper.php b/system/helpers/language_helper.php
index 4d571a7..d7aa8e6 100644
--- a/system/helpers/language_helper.php
+++ b/system/helpers/language_helper.php
@@ -52,8 +52,7 @@
*/
function lang($line, $for = '', $attributes = array())
{
- $CI =& get_instance();
- $line = $CI->lang->line($line);
+ $line = get_instance()->lang->line($line);
if ($for !== '')
{
diff --git a/system/helpers/security_helper.php b/system/helpers/security_helper.php
index 4bb94a2..7a6df54 100644
--- a/system/helpers/security_helper.php
+++ b/system/helpers/security_helper.php
@@ -49,8 +49,7 @@
*/
function xss_clean($str, $is_image = FALSE)
{
- $CI =& get_instance();
- return $CI->security->xss_clean($str, $is_image);
+ return get_instance()->security->xss_clean($str, $is_image);
}
}
@@ -66,8 +65,7 @@
*/
function sanitize_filename($filename)
{
- $CI =& get_instance();
- return $CI->security->sanitize_filename($filename);
+ return get_instance()->security->sanitize_filename($filename);
}
}
@@ -107,8 +105,7 @@
*/
function strip_image_tags($str)
{
- $CI =& get_instance();
- return $CI->security->strip_image_tags($str);
+ return get_instance()->security->strip_image_tags($str);
}
}
diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php
index b0f4368..2d92897 100644
--- a/system/helpers/url_helper.php
+++ b/system/helpers/url_helper.php
@@ -91,8 +91,7 @@
*/
function current_url()
{
- $CI =& get_instance();
- return $CI->config->site_url($CI->uri->uri_string());
+ return get_instance()->config->site_url($CI->uri->uri_string());
}
}
@@ -109,8 +108,7 @@
*/
function uri_string()
{
- $CI =& get_instance();
- return $CI->uri->uri_string();
+ return get_instance()->uri->uri_string();
}
}
@@ -127,8 +125,7 @@
*/
function index_page()
{
- $CI =& get_instance();
- return $CI->config->item('index_page');
+ return get_instance()->config->item('index_page');
}
}