summaryrefslogtreecommitdiffstats
path: root/system
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2014-02-17 17:51:48 +0100
committerAndrey Andreev <narf@devilix.net>2014-02-17 17:51:48 +0100
commitffe8aded4d2210759fce3427ed04893e6c655006 (patch)
tree8ba0117147e1c6b7f14c26f8a9715c0f7305d013 /system
parent3ddd564ca90b9296775c92566af942468a9ee358 (diff)
Micro-optimizations
Diffstat (limited to 'system')
-rw-r--r--system/helpers/file_helper.php1
-rw-r--r--system/libraries/Ftp.php75
-rw-r--r--system/libraries/Pagination.php36
3 files changed, 56 insertions, 56 deletions
diff --git a/system/helpers/file_helper.php b/system/helpers/file_helper.php
index 575b87479..b8b70534f 100644
--- a/system/helpers/file_helper.php
+++ b/system/helpers/file_helper.php
@@ -267,7 +267,6 @@ if ( ! function_exists('get_file_info'))
*/
function get_file_info($file, $returned_values = array('name', 'server_path', 'size', 'date'))
{
-
if ( ! file_exists($file))
{
return FALSE;
diff --git a/system/libraries/Ftp.php b/system/libraries/Ftp.php
index ef3b7d70d..991769a6a 100644
--- a/system/libraries/Ftp.php
+++ b/system/libraries/Ftp.php
@@ -463,28 +463,26 @@ class CI_FTP {
$filepath = preg_replace('/(.+?)\/*$/', '\\1/', $filepath);
$list = $this->list_files($filepath);
-
- if ($list !== FALSE && count($list) > 0)
+ if ( ! empty($list))
{
- foreach ($list as $item)
+ for ($i = 0, $c = count($list); $i < $c; $i++)
{
- // If we can't delete the item it's probaly a folder so
- // we'll recursively call delete_dir()
- if ( ! @ftp_delete($this->conn_id, $item))
+ // If we can't delete the item it's probaly a directory,
+ // so we'll recursively call delete_dir()
+ if ( ! @ftp_delete($this->conn_id, $list[$i]))
{
- $this->delete_dir($item);
+ $this->delete_dir($list[$i]);
}
}
}
- $result = @ftp_rmdir($this->conn_id, $filepath);
-
- if ($result === FALSE)
+ if (@ftp_rmdir($this->conn_id, $filepath) === FALSE)
{
if ($this->debug === TRUE)
{
$this->_error('ftp_unable_to_delete');
}
+
return FALSE;
}
@@ -507,14 +505,13 @@ class CI_FTP {
return FALSE;
}
- $result = @ftp_chmod($this->conn_id, $perm, $path);
-
- if ($result === FALSE)
+ if (@ftp_chmod($this->conn_id, $perm, $path) === FALSE)
{
if ($this->debug === TRUE)
{
$this->_error('ftp_unable_to_chmod');
}
+
return FALSE;
}
@@ -531,12 +528,9 @@ class CI_FTP {
*/
public function list_files($path = '.')
{
- if ( ! $this->_is_conn())
- {
- return FALSE;
- }
-
- return ftp_nlist($this->conn_id, $path);
+ return $this->_is_conn()
+ ? ftp_nlist($this->conn_id, $path)
+ : FALSE;
}
// ------------------------------------------------------------------------
@@ -585,6 +579,7 @@ class CI_FTP {
$this->upload($locpath.$file, $rempath.$file, $mode);
}
}
+
return TRUE;
}
@@ -601,13 +596,12 @@ class CI_FTP {
*/
protected function _getext($filename)
{
- if (FALSE === strpos($filename, '.'))
+ if (($dot = strrpos($filename, '.')) === FALSE)
{
return 'txt';
}
- $x = explode('.', $filename);
- return end($x);
+ return substr($filename, $dot + 1);
}
// --------------------------------------------------------------------
@@ -621,20 +615,20 @@ class CI_FTP {
protected function _settype($ext)
{
$text_types = array(
- 'txt',
- 'text',
- 'php',
- 'phps',
- 'php4',
- 'js',
- 'css',
- 'htm',
- 'html',
- 'phtml',
- 'shtml',
- 'log',
- 'xml'
- );
+ 'txt',
+ 'text',
+ 'php',
+ 'phps',
+ 'php4',
+ 'js',
+ 'css',
+ 'htm',
+ 'html',
+ 'phtml',
+ 'shtml',
+ 'log',
+ 'xml'
+ );
return in_array($ext, $text_types) ? 'ascii' : 'binary';
}
@@ -648,12 +642,9 @@ class CI_FTP {
*/
public function close()
{
- if ( ! $this->_is_conn())
- {
- return FALSE;
- }
-
- return @ftp_close($this->conn_id);
+ return $this->_is_conn()
+ ? @ftp_close($this->conn_id)
+ : FALSE;
}
// ------------------------------------------------------------------------
diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php
index 99552ec0d..da2fe7400 100644
--- a/system/libraries/Pagination.php
+++ b/system/libraries/Pagination.php
@@ -294,6 +294,13 @@ class CI_Pagination {
*/
protected $data_page_attr = 'data-ci-pagination-page';
+ /**
+ * CI Singleton
+ *
+ * @var object
+ */
+ protected $CI;
+
// --------------------------------------------------------------------
/**
@@ -304,11 +311,11 @@ class CI_Pagination {
*/
public function __construct($params = array())
{
- $CI =& get_instance();
- $CI->load->language('pagination');
+ $this->CI =& get_instance();
+ $this->CI->load->language('pagination');
foreach (array('first_link', 'next_link', 'prev_link', 'last_link') as $key)
{
- if (($val = $CI->lang->line('pagination_'.$key)) !== FALSE)
+ if (($val = $this->CI->lang->line('pagination_'.$key)) !== FALSE)
{
$this->$key = $val;
}
@@ -350,6 +357,11 @@ class CI_Pagination {
}
}
+ if ($this->CI->config->item('enable_query_strings') === TRUE)
+ {
+ $this->page_query_string = TRUE;
+ }
+
return $this;
}
@@ -386,13 +398,11 @@ class CI_Pagination {
show_error('Your number of links must be a positive number.');
}
- $CI =& get_instance();
-
// Keep any existing query string items.
// Note: Has nothing to do with any other query string option.
if ($this->reuse_query_string === TRUE)
{
- $get = $CI->input->get();
+ $get = $this->CI->input->get();
// Unset the controll, method, old-school routing options
unset($get['c'], $get['m'], $get[$this->query_string_segment]);
@@ -411,7 +421,7 @@ class CI_Pagination {
$query_string_sep = (strpos($base_url, '?') === FALSE) ? '?' : '&amp;';
// Are we using query strings?
- if ($CI->config->item('enable_query_strings') === TRUE OR $this->page_query_string === TRUE)
+ if ($this->page_query_string === TRUE)
{
// If a custom first_url hasn't been specified, we'll create one from
// the base_url, but without the page item.
@@ -459,19 +469,19 @@ class CI_Pagination {
$base_page = ($this->use_page_numbers) ? 1 : 0;
// Are we using query strings?
- if ($CI->config->item('enable_query_strings') === TRUE OR $this->page_query_string === TRUE)
+ if ($this->page_query_string === TRUE)
{
- $this->cur_page = $CI->input->get($this->query_string_segment);
+ $this->cur_page = $this->CI->input->get($this->query_string_segment);
}
else
{
// Default to the last segment number if one hasn't been defined.
if ($this->uri_segment === 0)
{
- $this->uri_segment = count($CI->uri->segment_array());
+ $this->uri_segment = count($this->CI->uri->segment_array());
}
- $this->cur_page = $CI->uri->segment($this->uri_segment);
+ $this->cur_page = $this->CI->uri->segment($this->uri_segment);
// Remove any specified prefix/suffix from the segment.
if ($this->prefix !== '' OR $this->suffix !== '')
@@ -629,8 +639,8 @@ class CI_Pagination {
{
isset($attributes['rel']) OR $attributes['rel'] = TRUE;
$this->_link_types = ($attributes['rel'])
- ? array('start' => 'start', 'prev' => 'prev', 'next' => 'next')
- : array();
+ ? array('start' => 'start', 'prev' => 'prev', 'next' => 'next')
+ : array();
unset($attributes['rel']);
$this->_attributes = '';