Skip to content

Loading…

[YAML] Improve performance of getNextEmbedBlock #10317

Merged
merged 1 commit into from

3 participants

@alexpott
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

@catch56

Yes this is straight duplication, looks good to me.

@fabpot fabpot added a commit that referenced this pull request
@fabpot fabpot 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.
eed7a86
@fabpot fabpot merged commit 995a033 into symfony:2.3

1 check passed

Details default Success: Travis, fabbot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 23, 2014
  1. Improve performance of getNextEmbedBlock by removing unnecessary preg…

    Alex Pott committed
    …_match and function calls.
Showing with 6 additions and 8 deletions.
  1. +6 −8 src/Symfony/Component/Yaml/Parser.php
View
14 src/Symfony/Component/Yaml/Parser.php
@@ -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();
Something went wrong with that request. Please try again.