- Small performance improvements

release-0.6
alecpl 16 years ago
parent ec581c106e
commit 2aa2b332f6

@ -700,7 +700,7 @@ function asciiwords($str, $css_id = false, $replace_with = '')
*/
function strip_quotes($str)
{
return preg_replace('/[\'"]/', '', $str);
return str_replace(array("'", '"'), '', $str);
}

@ -810,9 +810,9 @@ class rcmail
if (($attrib['uppercase'] && strtolower($attrib['uppercase']=='first')) || $attrib['ucfirst'])
return ucfirst($text);
else if ($attrib['uppercase'])
return strtoupper($text);
return mb_strtoupper($text);
else if ($attrib['lowercase'])
return strtolower($text);
return mb_strtolower($text);
return $text;
}
@ -874,7 +874,7 @@ class rcmail
if ($dh = @opendir(INSTALL_PATH . 'program/localization')) {
while (($name = readdir($dh)) !== false) {
if ($name{0}=='.' || !is_dir(INSTALL_PATH . 'program/localization/' . $name))
if ($name[0] == '.' || !is_dir(INSTALL_PATH . 'program/localization/' . $name))
continue;
if ($label = $rcube_languages[$name])

@ -30,25 +30,25 @@ class rcube_browser
{
function __construct()
{
$HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT'];
$HTTP_USER_AGENT = strtolower($_SERVER['HTTP_USER_AGENT']);
$this->ver = 0;
$this->win = stristr($HTTP_USER_AGENT, 'win');
$this->mac = stristr($HTTP_USER_AGENT, 'mac');
$this->linux = stristr($HTTP_USER_AGENT, 'linux');
$this->unix = stristr($HTTP_USER_AGENT, 'unix');
$this->win = strstr($HTTP_USER_AGENT, 'win');
$this->mac = strstr($HTTP_USER_AGENT, 'mac');
$this->linux = strstr($HTTP_USER_AGENT, 'linux');
$this->unix = strstr($HTTP_USER_AGENT, 'unix');
$this->opera = stristr($HTTP_USER_AGENT, 'opera');
$this->ns4 = stristr($HTTP_USER_AGENT, 'mozilla/4') && !stristr($HTTP_USER_AGENT, 'msie');
$this->ns = ($this->ns4 || stristr($HTTP_USER_AGENT, 'netscape'));
$this->ie = stristr($HTTP_USER_AGENT, 'compatible; msie') && !$this->opera;
$this->mz = stristr($HTTP_USER_AGENT, 'mozilla/5');
$this->chrome = stristr($HTTP_USER_AGENT, 'chrome');
$this->khtml = stristr($HTTP_USER_AGENT, 'khtml');
$this->safari = !$this->chrome && ($this->khtml || stristr($HTTP_USER_AGENT, 'safari'));
$this->opera = strstr($HTTP_USER_AGENT, 'opera');
$this->ns4 = strstr($HTTP_USER_AGENT, 'mozilla/4') && !strstr($HTTP_USER_AGENT, 'msie');
$this->ns = ($this->ns4 || strstr($HTTP_USER_AGENT, 'netscape'));
$this->ie = !$this->opera && strstr($HTTP_USER_AGENT, 'compatible; msie');
$this->mz = strstr($HTTP_USER_AGENT, 'mozilla/5');
$this->chrome = strstr($HTTP_USER_AGENT, 'chrome');
$this->khtml = strstr($HTTP_USER_AGENT, 'khtml');
$this->safari = !$this->chrome && ($this->khtml || strstr($HTTP_USER_AGENT, 'safari'));
if ($this->ns || $this->chrome) {
$test = preg_match('/(mozilla|chrome)\/([0-9.]+)/i', $HTTP_USER_AGENT, $regs);
$test = preg_match('/(mozilla|chrome)\/([0-9.]+)/', $HTTP_USER_AGENT, $regs);
$this->ver = $test ? (float)$regs[2] : 0;
}
else if ($this->mz) {
@ -56,11 +56,11 @@ class rcube_browser
$this->ver = $test ? (float)$regs[1] : 0;
}
else if ($this->ie || $this->opera) {
$test = preg_match('/(msie|opera) ([0-9.]+)/i', $HTTP_USER_AGENT, $regs);
$test = preg_match('/(msie|opera) ([0-9.]+)/', $HTTP_USER_AGENT, $regs);
$this->ver = $test ? (float)$regs[2] : 0;
}
if (preg_match('/ ([a-z]{2})-([a-z]{2})/i', $HTTP_USER_AGENT, $regs))
if (preg_match('/ ([a-z]{2})-([a-z]{2})/', $HTTP_USER_AGENT, $regs))
$this->lang = $regs[1];
else
$this->lang = 'en';

@ -3426,7 +3426,7 @@ class rcube_imap
$name = trim($val['name']);
if (preg_match('/^[\'"]/', $name) && preg_match('/[\'"]$/', $name))
$name = preg_replace(array('/^[\'"]/', '/[\'"]$/'), '', $name);
$name = trim($name, '\'"');
if ($name && $address && $name != $address)
$string = sprintf('%s <%s>', preg_match("/$special_chars/", $name) ? '"'.addcslashes($name, '"').'"' : $name, $address);
@ -3458,7 +3458,7 @@ class rcube_imap
function decode_header($input, $remove_quotes=false)
{
$str = rcube_imap::decode_mime_string((string)$input, $this->default_charset);
if ($str{0}=='"' && $remove_quotes)
if ($str[0] == '"' && $remove_quotes)
$str = str_replace('"', '', $str);
return $str;

@ -1258,7 +1258,7 @@ class rcube_imap_generic
}
break;
case 'in-reply-to':
$result[$id]->in_reply_to = preg_replace('/[\n<>]/', '', $string);
$result[$id]->in_reply_to = str_replace(array("\n", '<', '>'), '', $string);
break;
case 'references':
$result[$id]->references = $string;
@ -2115,7 +2115,7 @@ class rcube_imap_generic
// return false if not found, parse if found
$min_free = PHP_INT_MAX;
foreach ($quota_lines as $key => $quota_line) {
$quota_line = preg_replace('/[()]/', '', $quota_line);
$quota_line = str_replace(array('(', ')'), '', $quota_line);
$parts = explode(' ', $quota_line);
$storage_part = array_search('STORAGE', $parts);

@ -444,7 +444,10 @@ class rcube_template extends rcube_html_page
*/
public function abs_url($str)
{
return preg_replace('/^\//', $this->config['skin_path'].'/', $str);
if ($str[0] == '/')
return $this->config['skin_path'] . $str;
else
return $str;
}

Loading…
Cancel
Save