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:
parent
3bb24c20a6
commit
5ecfc42728
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user