From: x2003bruneau Date: Fri, 16 Nov 2007 09:25:19 +0000 (+0000) Subject: Some speed improvements again. X-Git-Tag: 1.8~5 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=0fa5e39a1910258f64f32bfcc50a82d3b77ea736;hp=951accf559f3dc5b3a2bbae9676d760c7a9f9ec9;p=banana.git Some speed improvements again. Signed-off-by: Florent Bruneau git-svn-id: svn+ssh://murphy/home/svn/banana/trunk@306 9869982d-c50d-0410-be91-f2a2ec7c7c7b --- diff --git a/banana/banana.inc.php.in b/banana/banana.inc.php.in index 26cb3a5..1311029 100644 --- a/banana/banana.inc.php.in +++ b/banana/banana.inc.php.in @@ -673,26 +673,7 @@ class Banana { Banana::load('spool'); if (!Banana::$spool || Banana::$spool->group != $group) { - $clean = false; - if (php_sapi_name() != 'cli') { - if ($group == @$_SESSION['banana_group'] && isset($_SESSION['banana_spool'])) { - Banana::$spool = unserialize($_SESSION['banana_spool']); - unset($_SESSION['banana_spool']); - $clean = @(Banana::$profile['lastnews'] != $_SESSION['banana_lastnews']); - } else { - unset($_SESSION['banana_message']); - unset($_SESSION['banana_artid']); - unset($_SESSION['banana_showhdr']); - } - } - BananaSpool::getSpool($group, Banana::$profile['lastnews'], Banana::$profile['autoup'] || $clean); - if (php_sapi_name() != 'cli') { - $_SESSION['banana_group'] = $group; - if (!Banana::$profile['display']) { - $_SESSION['banana_spool'] = serialize(Banana::$spool); - $_SESSION['banana_lastnews'] = Banana::$profile['lastnews']; - } - } + BananaSpool::getSpool($group, Banana::$profile['lastnews'], Banana::$profile['autoup']); Banana::$spool->setMode(Banana::$profile['display'] ? Banana::SPOOL_UNREAD : Banana::SPOOL_ALL); } return true; diff --git a/banana/nntp.inc.php b/banana/nntp.inc.php index 6245803..a9b7be0 100644 --- a/banana/nntp.inc.php +++ b/banana/nntp.inc.php @@ -76,10 +76,10 @@ class BananaNNTP extends BananaNNTPCore implements BananaProtocoleInterface if (!is_utf8($desc)) { $desc = utf8_encode($desc); } - $this->boxes[$group] = array('desc' => $desc); + $this->boxes[$group] = array('desc' => $desc); } else { $this->boxes[$group] = array('desc' => null); - } + } } ksort($this->boxes); } diff --git a/banana/nntpcore.inc.php b/banana/nntpcore.inc.php index 4b8e9c0..3029c08 100644 --- a/banana/nntpcore.inc.php +++ b/banana/nntpcore.inc.php @@ -100,9 +100,10 @@ class BananaNNTPCore /** get a line from server * @return STRING */ - private function getLine() + private function &getLine() { - return rtrim(@fgets($this->ns, 1200), "\r\n"); + $data = rtrim(@fgets($this->ns, 1200), "\r\n"); + return $data; } /** fetch data (and on delimitor) @@ -111,11 +112,13 @@ class BananaNNTPCore private function &fetchResult() { $array = Array(); - while (($result = $this->getLine()) != '.') { - $array[] = $result; + while (($result =& $this->getLine()) != '.') { + $array[] =& $result; } if ($this->debug && $this->bt) { - $this->bt[count($this->bt) - 1]['response'] = count($array); + $trace =& $this->bt[count($this->bt) - 1]; + $trace['response'] = count($array); + $trace['time'] = microtime(true) - $trace['start']; } return $array; } @@ -131,7 +134,7 @@ class BananaNNTPCore } if ($this->debug) { $db_line = preg_replace('/PASS .*/', 'PASS *******', $line); - $this->bt[] = array('action' => $db_line, 'time' => microtime(true)); + $this->bt[] = array('action' => $db_line, 'start' => microtime(true)); } return @fputs($this->ns, $line, strlen($line)); } @@ -172,7 +175,7 @@ class BananaNNTPCore $this->lastresulttext = substr($result, 4); if ($this->debug && $this->bt) { $trace =& $this->bt[count($this->bt) - 1]; - $trace['time'] = microtime(true) - $trace['time']; + $trace['time'] = microtime(true) - $trace['start']; $trace['code'] = $this->lastresultcode; $trace['message'] = $this->lastresulttext; $trace['response'] = 0; diff --git a/banana/tree.inc.php b/banana/tree.inc.php index 09fe261..e19e6ab 100644 --- a/banana/tree.inc.php +++ b/banana/tree.inc.php @@ -95,19 +95,21 @@ class BananaTree if (!is_null($this->displaid) || is_null($this->data)) { return $this->displaid; } - static $t_e, $u_h, $u_ht, $u_vt, $u_l, $u_f, $r_h, $r_ht, $r_vt, $r_l, $r_f; + static $t_e, $tree; + //$u_h, $u_ht, $u_vt, $u_l, $u_f, $r_h, $r_ht, $r_vt, $r_l, $r_f; if (!isset($t_e)) { + $tree = array(); $t_e = Banana::$page->makeImg(Array('img' => 'e', 'alt' => ' ', 'height' => 18, 'width' => 14)); - $u_h = Banana::$page->makeImg(Array('img' => 'h2', 'alt' => '-', 'height' => 18, 'width' => 14)); - $u_ht = Banana::$page->makeImg(Array('img' => 'T2', 'alt' => '+', 'height' => 18, 'width' => 14)); - $u_vt = Banana::$page->makeImg(Array('img' => 't2', 'alt' => '`', 'height' => 18, 'width' => 14)); - $u_l = Banana::$page->makeImg(Array('img' => 'l2', 'alt' => '|', 'height' => 18, 'width' => 14)); - $u_f = Banana::$page->makeImg(Array('img' => 'f2', 'alt' => 't', 'height' => 18, 'width' => 14)); - $r_h = Banana::$page->makeImg(Array('img' => 'h2r', 'alt' => '-', 'height' => 18, 'width' => 14)); - $r_ht = Banana::$page->makeImg(Array('img' => 'T2r', 'alt' => '+', 'height' => 18, 'width' => 14)); - $r_vt = Banana::$page->makeImg(Array('img' => 't2r', 'alt' => '`', 'height' => 18, 'width' => 14)); - $r_l = Banana::$page->makeImg(Array('img' => 'l2r', 'alt' => '|', 'height' => 18, 'width' => 14)); - $r_f = Banana::$page->makeImg(Array('img' => 'f2r', 'alt' => 't', 'height' => 18, 'width' => 14)); + $tree['+'] = array(Banana::$page->makeImg(Array('img' => 'T2', 'alt' => '-', 'height' => 18, 'width' => 14)), + Banana::$page->makeImg(Array('img' => 'T2r', 'alt' => '+', 'height' => 18, 'width' => 14))); + $tree['-'] = array(Banana::$page->makeImg(Array('img' => 'h2', 'alt' => '-', 'height' => 18, 'width' => 14)), + Banana::$page->makeImg(Array('img' => 'h2r', 'alt' => '-', 'height' => 18, 'width' => 14))); + $tree['|'] = array(Banana::$page->makeImg(Array('img' => 'l2', 'alt' => '|', 'height' => 18, 'width' => 14)), + Banana::$page->makeImg(Array('img' => 'l2r', 'alt' => '|', 'height' => 18, 'width' => 14))); + $tree['`'] = array(Banana::$page->makeImg(Array('img' => 't2', 'alt' => '`', 'height' => 18, 'width' => 14)), + Banana::$page->makeImg(Array('img' => 't2r', 'alt' => '`', 'height' => 18, 'width' => 14))); + $tree['t'] = array(Banana::$page->makeImg(Array('img' => 'f2', 'alt' => 't', 'height' => 18, 'width' => 14)), + Banana::$page->makeImg(Array('img' => 'f2r', 'alt' => 't', 'height' => 18, 'width' => 14))); } $text = '
'; foreach ($this->data as &$line) { @@ -117,18 +119,11 @@ class BananaTree $text .= $t_e; } else if (is_array($item)) { $head =& Banana::$spool->overview[$item[1]]; - switch ($item[0]) { - case '+': $text .= $head->isread ? $r_ht : $u_ht; break; - case '-': $text .= $head->isread ? $r_h : $u_h; break; - case '|': $text .= $head->isread ? $r_l : $u_l; break; - case '`': $text .= $head->isread ? $r_vt : $u_vt; break; - case 't': $text .= $head->isread ? $r_f : $u_f; break; - } + $text .= $tree[$item[0]][$head->isread ? 1 : 0]; } else { $head =& Banana::$spool->overview[$item]; - $text .= '' - . 'color . '; text-decoration: none" title="' + . $this->title[$item] . '">urls[$item] . '\'"'; } else {