Skip to content

Commit

Permalink
Avoid unnecessarily generating separator string multiple times.
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Oct 5, 2016
1 parent f9e3b56 commit 0c17f71
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/View/Helper/BreadcrumbsHelper.php
Expand Up @@ -217,6 +217,7 @@ public function render(array $attributes = [], array $separator = [])
$crumbs = $this->crumbs;
$crumbsCount = count($crumbs);
$templater = $this->templater();
$separatorString = '';

if ($separator) {
if (isset($separator['innerAttrs'])) {
Expand All @@ -227,6 +228,8 @@ public function render(array $attributes = [], array $separator = [])
$separator,
['innerAttrs', 'separator']
);

$separatorString = $this->formatTemplate('separator', $separator);
}

$crumbTrail = '';
Expand Down Expand Up @@ -255,8 +258,8 @@ public function render(array $attributes = [], array $separator = [])
$template = 'itemWithoutLink';
}

if ($separator && $key !== ($crumbsCount - 1)) {
$templateParams['separator'] = $this->formatTemplate('separator', $separator);
if ($separatorString && $key !== ($crumbsCount - 1)) {
$templateParams['separator'] = $separatorString;
}

$crumbTrail .= $this->formatTemplate($template, $templateParams);
Expand Down

0 comments on commit 0c17f71

Please sign in to comment.