Skip to content

Commit

Permalink
Improve performance of getNextEmbedBlock by removing unnecessary preg…
Browse files Browse the repository at this point in the history
…_match and function calls.
  • Loading branch information
alexpott committed Feb 23, 2014
1 parent 6b0b504 commit 995a033
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/Symfony/Component/Yaml/Parser.php
Expand Up @@ -323,18 +323,16 @@ private function getNextEmbedBlock($indentation = null)
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 ($removeComments && $this->isCurrentLineComment()) {
continue;
}

if (preg_match('#^(?P<text> *)$#', $this->currentLine, $match)) {
// empty line
$data[] = $match['text'];
} elseif ($indent >= $newIndent) {
if ($indent >= $newIndent) {
$data[] = substr($this->currentLine, $newIndent);
} elseif (0 == $indent) {
$this->moveToPreviousLine();
Expand Down

0 comments on commit 995a033

Please sign in to comment.