Permalink
Browse files

Bug 678688 - Break up FullLogGenerator::getLog into parts in order to…

… make it slightly clearer where time is spent when looking at profiles. r=arpad.borsos
  • Loading branch information...
mstange committed Aug 13, 2011
1 parent 2fed274 commit 154ece76f941a50398f136179a6fdb8430cc0727
Showing with 22 additions and 14 deletions.
  1. +22 −14 php/inc/FullLogGenerator.php
@@ -17,24 +17,32 @@ protected function getType() {
return "full";
}
+ private function encodeLines($lines) {
+ $numLines = count($lines);
+ $encodedLines = array($numLines);
+ for ($i = 0; $i < $numLines; $i++) {
+ $encodedLines[$i] = htmlspecialchars($lines[$i]);
+ }
+ return $encodedLines;
+ }
+
+ private function linkLinesWithErrors($lines, $linesWithErrors) {
+ foreach ($linesWithErrors as $errorNumber => $lineWithError) {
+ $lines[$i] = '<strong id="error'.$errorNumber.'">'.$lines[$i].'</strong>';
+ }
+ }
+
+ private function mergeToPRE($lines) {
+ return '<pre>'.implode("", $lines).'</pre>';
+ }
+
protected function getLog() {
$lines = $this->logParser->getLines();
$numLines = count($lines);
$linesWithErrors = $this->logParser->getFilteredLines();
- $errorCount = count($linesWithErrors);
- $upcomingErrorNumber = 0;
- $upcomingErrorLine = $upcomingErrorNumber < $errorCount ? $linesWithErrors[$upcomingErrorNumber] : -1;
- $transformedLines = array();
- for ($i = 0; $i < $numLines; $i++) {
- if ($i == $upcomingErrorLine) {
- $transformedLines[] = '<strong id="error'.$upcomingErrorNumber.'">'.htmlspecialchars($lines[$i]).'</strong>';
- $upcomingErrorNumber++;
- $upcomingErrorLine = $upcomingErrorNumber < $errorCount ? $linesWithErrors[$upcomingErrorNumber] : -1;
- } else {
- $transformedLines[] = htmlspecialchars($lines[$i]);
- }
- }
- return '<pre>'.implode("", $transformedLines).'</pre>';
+ $transformedLines = $this->encodeLines($lines);
+ $this->linkLinesWithErrors($transformedLines, $linesWithErrors);
+ return $this->mergeToPRE($transformedLines);
}
protected function generateHTML($summary, $fullLog) {

0 comments on commit 154ece7

Please sign in to comment.