Use mutating loop instead of creating new array

This commit is contained in:
Aidan Woods 2018-04-08 17:49:36 +01:00
parent cdaf86b039
commit 86940be224
No known key found for this signature in database
GPG Key ID: 9A6A8EFAA512BBB9
1 changed files with 6 additions and 10 deletions

View File

@ -1664,26 +1664,22 @@ class Parsedown
protected function elementsApplyRecursive($closure, array $Elements)
{
$newElements = array();
foreach ($Elements as $Element)
foreach ($Elements as &$Element)
{
$newElements[] = $this->elementApplyRecursive($closure, $Element);
$Element = $this->elementApplyRecursive($closure, $Element);
}
return $newElements;
return $Elements;
}
protected function elementsApplyRecursiveDepthFirst($closure, array $Elements)
{
$newElements = array();
foreach ($Elements as $Element)
foreach ($Elements as &$Element)
{
$newElements[] = $this->elementApplyRecursiveDepthFirst($closure, $Element);
$Element = $this->elementApplyRecursiveDepthFirst($closure, $Element);
}
return $newElements;
return $Elements;
}
protected function element(array $Element)