From efec6f6ec9e712413a6693ec531180cb69fd2f20 Mon Sep 17 00:00:00 2001 From: Denis Flaven Date: Mon, 6 Jul 2015 13:04:24 +0000 Subject: [PATCH] Performance optimization: cache the result of the disk scan looking for icons for dashboards SVN:trunk[3620] --- application/forms.class.inc.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/application/forms.class.inc.php b/application/forms.class.inc.php index 82601b485..d7c928698 100644 --- a/application/forms.class.inc.php +++ b/application/forms.class.inc.php @@ -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); }