Improved the performance of remove_remarks() by an order of magnitude.

git-svn-id: file:///svn/phpbb/trunk@1063 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
natec 2001-09-23 00:31:56 +00:00
parent fa76b50795
commit 2ea142d935

View file

@ -659,24 +659,26 @@ function output_table_content($content)
// //
function remove_remarks($sql) function remove_remarks($sql)
{ {
$i = 0; $lines = explode("\n", $sql);
$linecount = count($lines);
$output = "";
while($i < strlen($sql)) for ($i = 0; $i < $linecount; $i++)
{ {
if( $sql[$i] == "#" && ( $sql[$i-1] == "\n" || $i==0 ) ) if (($i != ($linecount - 1)) || (strlen($lines[$i]) > 0))
{ {
$j = 1; if ($lines[$i][0] != "#")
while( $sql[$i + $j] != "\n" )
{ {
$j++; $output .= $lines[$i] . "\n";
}
else
{
$output .= "\n";
} }
$sql = substr($sql,0,$i) . substr($sql,$i+$j);
} }
$i++;
} }
return($sql); return $output;
} }