This is probably faster than duplicating the closure

This commit is contained in:
Aidan Woods 2018-04-01 17:55:32 +01:00
parent 9026b1abdb
commit 390fa0da1b
No known key found for this signature in database
GPG Key ID: 9A6A8EFAA512BBB9
1 changed files with 7 additions and 4 deletions

View File

@ -1614,10 +1614,13 @@ class Parsedown
protected function elementsApplyRecursive($closure, array $Elements)
{
return array_map(
array($this, 'elementApplyRecursive'),
array_fill(0, count($Elements), $closure),
$Elements
return array_reduce(
$Elements,
function (array $Elements, array $Element) use ($closure) {
$Elements[] = $this->elementApplyRecursive($closure, $Element);
return $Elements;
},
array()
);
}