From 11873d857804150410569b8b7bac823b5f1964db Mon Sep 17 00:00:00 2001 From: x2000habouzit Date: Fri, 31 Dec 2004 15:00:19 +0000 Subject: [PATCH] corrections + performance : 30% of gain in gline with a simple preg_replace ---> trim --- include/NetNNTP.inc.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/include/NetNNTP.inc.php b/include/NetNNTP.inc.php index 4d167b7..9b55740 100644 --- a/include/NetNNTP.inc.php +++ b/include/NetNNTP.inc.php @@ -29,11 +29,12 @@ class nntp { */ function gline() { - $line = preg_replace("/(\r|\n)/", "", fgets($this->ns, 1200)); if ($this->debug) { + $line = trim(fgets($this->ns, 1200)); print "NNTP >>>> $line \n"; + return $line; } - return $line; + return trim(fgets($this->ns, 1200)); } /** puts a line on server @@ -238,7 +239,7 @@ class nntp { if (preg_match("/^2\d{2} (\d+) (\d+) (\d+) ([^ ]+)/", $line, $regs)) { return array($regs[1], $regs[2], $regs[3], $regs[4]); } - return $false; + return false; } /** set the article pointer to the previous article in current group @@ -257,7 +258,7 @@ class nntp { if (preg_match("/^2\d{2} \d+ <([^>]+)>/", $line, $regs)) { return "<{$regs[1]}>"; } - return $false; + return false; } /** set the article pointer to the next article in current group @@ -276,7 +277,7 @@ class nntp { if (preg_match("/^2\d{2} \d+ <([^>]+)>/", $line, $regs)) { return "<{$regs[1]}>"; } - return $false; + return false; } /** set the current article pointer @@ -461,12 +462,11 @@ class nntp { if (substr($this->gline(), 0, 1)!="2") { return false; } - $result = $this->gline(); + $array = array(); - while ($result != ".") { + while (($result = $this->gline()) != '.') { preg_match("/([^ \t]+) (.*)$/", $result, $regs); $array[$regs[1]] = $regs[2]; - $result = $this->gline(); } return $array; } -- 2.1.4