Improve performance of getNextEmbedBlock by removing unnecessary preg_match and function calls.

This commit is contained in:
Alex Pott 2014-02-23 21:20:36 +00:00
parent 6b0b504348
commit 995a033243

View File

@ -323,18 +323,16 @@ class Parser
break;
}
if ($removeComments && $this->isCurrentLineEmpty() || $this->isCurrentLineBlank()) {
if ($this->isCurrentLineBlank()) {
$data[] = substr($this->currentLine, $newIndent);
}
if ($this->isCurrentLineBlank()) {
$data[] = substr($this->currentLine, $newIndent);
continue;
}
if (preg_match('#^(?P<text> *)$#', $this->currentLine, $match)) {
// empty line
$data[] = $match['text'];
} elseif ($indent >= $newIndent) {
if ($removeComments && $this->isCurrentLineComment()) {
continue;
}
if ($indent >= $newIndent) {
$data[] = substr($this->currentLine, $newIndent);
} elseif (0 == $indent) {
$this->moveToPreviousLine();