Welcome Guest, Not a member yet? Register   Sign In
Small optimization
#1

[eluser]Seppo[/eluser]
CI_Calendar::get_total_days use, instead
Code:
date('t', mktime(0, 0, 0, $month, 1, $year)

CI_Config:Confusedystem_url reduce to:
Code:
return $this->slash_item('base_url') . basename(BASEPATH) . '/'"

CI_Loader::model replacing rows 131-134 for
Code:
$path = dirname($model) . '/';
$model = basename($model);

CI_Session:Confusedtrip_slashes can use the string helper function strip_slashes, in an attempt to DRY.

CI_Upload::get_extension use
Code:
pathinfo($filename, PATHINFO_EXTENSION);

CI_Output::_display_cache suggest to rename $uri or $URI... it's confusing

CI_URI::_parse_request_uri optimization
Code:
$request_uri = preg_replace("|/(.*)|", "\\1", str_replace("\\", "/", $_SERVER['REQUEST_URI']));
//for
$request_uri = ltrim(str_replace("\\", "/", $_SERVER['REQUEST_URI']), '/');

CI_URI::_remove_url_suffix optimization
Code:
$this->uri_string = preg_replace("|".preg_quote($this->config->item('url_suffix'))."$|", "", $this->uri_string);
//for
$this->uri_string = basename($this->uri_string, $this->config->item('url_suffix'));

CI_URI::_explode_segments optimization
Code:
foreach(explode("/", preg_replace("|/*(.+?)/*$|", "\\1", $this->uri_string)) as $val)
{
    // Filter segments for security
    $val = trim($this->_filter_uri($val));

    if ($val != '')
        $this->segments[] = $val;
}
//
foreach(explode("/", preg_replace('#/(/|\s)+#','/',trim($uri_string, '/'))) as $val)
{
    // Filter segments for security
    $val = trim($this->_filter_uri($val));
    $this->segments[] = $val;
}




Theme © iAndrew 2016 - Forum software by © MyBB