Skip to content

Commit

Permalink
2 to 1 loop optimization in plugins/search/categories/categories.php (j…
Browse files Browse the repository at this point in the history
…oomla#13390)

* Another lonely `for` to `foreach`modification...

* Too much code for today... not seing the obvious... 😄

* Implementing a good catch by @andrepereiradasilva

* Optimized loop further
  • Loading branch information
frankmayer authored and wilsonge committed Dec 29, 2016
1 parent 7aa43fd commit 89b8136
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions plugins/search/categories/categories.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,19 +184,15 @@ public function onContentSearch($text, $phrase = '', $ordering = '', $areas = nu

if ($rows)
{
$count = count($rows);

for ($i = 0; $i < $count; $i++)
foreach ($rows as $i => $row)
{
$rows[$i]->href = ContentHelperRoute::getCategoryRoute($rows[$i]->slug);
$rows[$i]->section = JText::_('JCATEGORY');
}

foreach ($rows as $category)
{
if (searchHelper::checkNoHtml($category, $searchText, array('name', 'title', 'text')))
if (searchHelper::checkNoHtml($row, $searchText, array('name', 'title', 'text')))
{
$return[] = $category;
$row->href = ContentHelperRoute::getCategoryRoute($row->slug);
$row->section = JText::_('JCATEGORY');

$return[] = $row;
}
}
}
Expand Down

0 comments on commit 89b8136

Please sign in to comment.