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:
parent
a72455c78a
commit
8d09320009
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user