For the performance, here is the bad coding for Gantry.php that will cause multiple template styles query. This can be verified by enable debug mode...
The following 2 functions: getMasters() and getGantryTemplates()
can be combined into one function with only one query to $this->getTemplates();
this will reduce SQL query to database
private function getMasters()
{
$templates = $this->getTemplates();
$masters = array();
foreach ($templates as $template)
{
if ($template->params->get('master') == 'true')
{
$masters[] = $template->id;
}
}
return $masters;
}
private function getGantryTemplates()
{
$templates = $this->getTemplates();
$gantry = array();
foreach ($templates as $template)
{
if ($template->params->get('master') != null)
{
$gantry[] = $template->id;
}
}
Simple combining the function will not reduce the number of SQL queries made since the function will have to be called the same number of times as each of the individual functions is made anyways. As well the getTemplates function itself is cached internally so the SQL call is made only one time no matter how many time the wrapping functions call it. This is an internal cache and not dependent on Joomla caching being enabled or disabled.