[Yaml] Small optimization of the parser

This commit is contained in:
Guilhem N 2016-12-07 17:45:19 +01:00
parent d6e8937e69
commit 5fc8e865ce
No known key found for this signature in database
GPG Key ID: 9E5D2DB67BF054DD

View File

@ -400,7 +400,7 @@ class Parser
$blockScalarIndentations = array();
if ($this->isBlockScalarHeader()) {
$blockScalarIndentations[] = $this->getCurrentLineIndentation();
$blockScalarIndentations[] = $oldLineIndentation;
}
if (!$this->moveToNextLine()) {
@ -450,14 +450,14 @@ class Parser
// terminate all block scalars that are more indented than the current line
if (!empty($blockScalarIndentations) && $indent < $previousLineIndentation && trim($this->currentLine) !== '') {
foreach ($blockScalarIndentations as $key => $blockScalarIndentation) {
if ($blockScalarIndentation >= $this->getCurrentLineIndentation()) {
if ($blockScalarIndentation >= $indent) {
unset($blockScalarIndentations[$key]);
}
}
}
if (empty($blockScalarIndentations) && !$this->isCurrentLineComment() && $this->isBlockScalarHeader()) {
$blockScalarIndentations[] = $this->getCurrentLineIndentation();
$blockScalarIndentations[] = $indent;
}
$previousLineIndentation = $indent;