1
0
mirror of https://github.com/erusev/parsedown.git synced 2023-08-10 21:13:06 +03:00

Early exit if found

This commit is contained in:
Aidan Woods 2019-02-10 19:27:14 +00:00
parent 3bb24c20a6
commit 5ecfc42728
No known key found for this signature in database
GPG Key ID: 9A6A8EFAA512BBB9

View File

@ -26,21 +26,18 @@ final class Lines
$this->trailingBlankLinesText = $trailingBlankLinesText;
$this->trailingBlankLines = \substr_count($trailingBlankLinesText, "\n");
$this->containsBlankLines = (
($this->trailingBlankLines > 0)
|| \array_reduce(
$Contexts,
/**
* @param bool $blankFound
* @param Context $Context
* @return bool
*/
function ($blankFound, $Context) {
return $blankFound || ($Context->previousEmptyLines() > 0);
},
false
)
);
$containsBlankLines = $this->trailingBlankLines > 0;
if (! $containsBlankLines) {
foreach ($Contexts as $Context) {
if ($Context->previousEmptyLines() > 0) {
$containsBlankLines = true;
break;
}
}
}
$this->containsBlankLines = $containsBlankLines;
}
/** @return self */