8000 minor #10317 [YAML] Improve performance of getNextEmbedBlock (alexpott) · symfony/symfony@eed7a86 · GitHub
[go: up one dir, main page]

Skip to content

Commit eed7a86

Browse files
committed
minor #10317 [YAML] Improve performance of getNextEmbedBlock (alexpott)
This PR was merged into the 2.3 branch. Discussion ---------- [YAML] Improve performance of getNextEmbedBlock | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a By removing unnecessary preg_match and function calls - isCurrentLineEmpty() contains a call to isCurrentLineBlank() - therefore this function is called twice every time this condition is hit. The preg_match appears to legacy handling of blank lines. This improves the performance of the Drupal 8 installer. ![image](https://f.cloud.github.com/assets/769634/2241426/69effb0c-9cd1-11e3-9145-e4fabd2ec870.png) Commits ------- 995a033 Improve performance of getNextEmbedBlock by removing unnecessary preg_match and function calls.
2 parents 6b0b504 + 995a033 commit eed7a86

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/Symfony/Component/Yaml/Parser.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -323,18 +323,16 @@ private function getNextEmbedBlock($indentation = null)
323323
break;
324324
}
325325

326-
if ($removeComments && $this->isCurrentLineEmpty() || $this->isCurrentLineBlank()) {
327-
if ($this->isCurrentLineBlank()) {
328-
$data[] = substr($this->currentLine, $newIndent);
329-
}
326+
if ($this->isCurrentLineBlank()) {
327+
$data[] = substr($this->currentLine, $newIndent);
328+
continue;
329+
}
330330

331+
if ($removeComments && $this->isCurrentLineComment()) {
331332
continue;
332333
}
333334

334-
if (preg_match('#^(?P<text> *)$#', $this->currentLine, $match)) {
335-
// empty line
336-
$data[] = $match['text'];
337-
} elseif ($indent >= $newIndent) {
335+
if ($indent >= $newIndent) {
338336
$data[] = substr($this->currentLine, $newIndent);
339337
} elseif (0 == $indent) {
340338
$this->moveToPreviousLine();

0 commit comments

Comments
 (0)
0