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

Compute on read optimisation for previousEmptyLines

This commit is contained in:
Aidan Woods 2020-01-19 15:31:33 +00:00
parent a72455c78a
commit 8d09320009
No known key found for this signature in database
GPG Key ID: 9A6A8EFAA512BBB9

View File

@ -7,7 +7,7 @@ final class Context
/** @var Line */
private $Line;
/** @var int */
/** @var int|null */
private $previousEmptyLines;
/** @var string */
@ -21,7 +21,7 @@ final class Context
{
$this->Line = $Line;
$this->previousEmptyLinesText = $previousEmptyLinesText;
$this->previousEmptyLines = \substr_count($previousEmptyLinesText, "\n");
$this->previousEmptyLines = null;
}
/** @return Line */
@ -33,6 +33,10 @@ final class Context
/** @return int */
public function previousEmptyLines()
{
if (! isset($this->previousEmptyLines)) {
$this->previousEmptyLines = \substr_count($this->previousEmptyLinesText, "\n");
}
return $this->previousEmptyLines;
}