浏览代码

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

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@3620 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 10 年之前
父节点
当前提交
4d6fd84ec1
共有 1 个文件被更改,包括 8 次插入3 次删除
  1. 8 3
      application/forms.class.inc.php

+ 8 - 3
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);
 		}