Performance optimization: cache the result of the disk scan looking for icons for dashboards

SVN:trunk[3620]
This commit is contained in:
Denis Flaven
2015-07-06 13:04:24 +00:00
parent 7f460eda5a
commit efec6f6ec9

View File

@@ -1345,14 +1345,19 @@ EOF
class RunTimeIconSelectionField extends DesignerIconSelectionField
{
static $aAllIcons = array();
public function __construct($sCode, $sLabel = '', $defaultValue = '')
{
parent::__construct($sCode, $sLabel, $defaultValue);
$aAllIcons = self::FindIconsOnDisk(APPROOT.'env-'.utils::GetCurrentEnvironment());
ksort($aAllIcons);
if (count(self::$aAllIcons) == 0)
{
self::$aAllIcons = self::FindIconsOnDisk(APPROOT.'env-'.utils::GetCurrentEnvironment());
ksort(self::$aAllIcons);
}
$aValues = array();
foreach($aAllIcons as $sFilePath)
foreach(self::$aAllIcons as $sFilePath)
{
$aValues[] = array('value' => $sFilePath, 'label' => basename($sFilePath), 'icon' => utils::GetAbsoluteUrlModulesRoot().$sFilePath);
}