Module: nagvis
Branch: master
Commit: 68cdb7983aed1a1100cf3dc79daaf8ea305b5208
URL:    
http://nagvis.git.sourceforge.net/git/gitweb.cgi?p=nagvis/nagvis;a=commit;h=68cdb7983aed1a1100cf3dc79daaf8ea305b5208

Author: LaMi <[email protected]>
Date:   Mon Mar 22 23:14:08 2010 +0100

Some small memory and cpu optimization by reducing getValue calls

---

 share/server/core/classes/objects/NagVisObject.php |   10 +++++++---
 share/server/core/classes/objects/NagVisShape.php  |   10 ++++++----
 .../core/classes/objects/NagVisStatefulObject.php  |   12 +++++++-----
 .../core/classes/objects/NagVisStatelessObject.php |    4 ++--
 4 files changed, 22 insertions(+), 14 deletions(-)

diff --git a/share/server/core/classes/objects/NagVisObject.php 
b/share/server/core/classes/objects/NagVisObject.php
index e114f95..95ddd0b 100644
--- a/share/server/core/classes/objects/NagVisObject.php
+++ b/share/server/core/classes/objects/NagVisObject.php
@@ -47,9 +47,6 @@ class NagVisObject {
        protected $hover_childs_limit;
        protected $label_show;
        
-       protected $iconPath;
-       protected $iconHtmlPath;
-       
        private static $sSortOrder = 'asc';
        
        /**
@@ -226,6 +223,13 @@ class NagVisObject {
                                $arr[$key] = $val;
                        }
                }
+
+               // Add special static options
+               if($this instanceof NagVisStatefulObject) {
+                       $arr['iconHtmlPath'] = 
NagVisStatefulObject::$iconHtmlPath;
+               } elseif($this instanceof NagVisStatelessObject) {
+                       $arr['iconHtmlPath'] = 
NagVisStatelessObject::$iconHtmlPath;
+               }
                
                // Save the number of members
                switch($this->getType()) {
diff --git a/share/server/core/classes/objects/NagVisShape.php 
b/share/server/core/classes/objects/NagVisShape.php
index 970d7af..411075d 100644
--- a/share/server/core/classes/objects/NagVisShape.php
+++ b/share/server/core/classes/objects/NagVisShape.php
@@ -37,8 +37,10 @@ class NagVisShape extends NagVisStatelessObject {
         * @author      Lars Michelsen <[email protected]>
         */
        public function __construct($CORE, $icon) {
-               $this->iconPath = $CORE->getMainCfg()->getValue('paths', 
'shape');
-               $this->iconHtmlPath = $CORE->getMainCfg()->getValue('paths', 
'htmlshape');
+               if(parent::iconPath === null) {
+                       parent::iconPath = 
$CORE->getMainCfg()->getValue('paths', 'shape');
+                       parent::iconHtmlPath = 
$CORE->getMainCfg()->getValue('paths', 'htmlshape');
+               }
                
                $this->icon = $icon;
                $this->type = 'shape';
@@ -98,10 +100,10 @@ class NagVisShape extends NagVisStatelessObject {
         * @author      Lars Michelsen <[email protected]>
         */
        private function setIconPath() {
-               if(preg_match('/^\[(.*)\]$/',$this->icon,$match) > 0) {
+               if(preg_match('/^\[(.*)\]$/', $this->icon, $match) > 0) {
                        $this->icon = $match[1];
                } else {
-                       $this->icon = $this->iconHtmlPath.$this->icon;
+                       $this->icon = parent::iconHtmlPath . $this->icon;
                }
        }
 }
diff --git a/share/server/core/classes/objects/NagVisStatefulObject.php 
b/share/server/core/classes/objects/NagVisStatefulObject.php
index 762ec2d..5b47564 100644
--- a/share/server/core/classes/objects/NagVisStatefulObject.php
+++ b/share/server/core/classes/objects/NagVisStatefulObject.php
@@ -48,8 +48,8 @@ class NagVisStatefulObject extends NagVisObject {
        protected $summary_in_downtime;
        protected $problem_has_been_acknowledged;
        
-       protected $iconPath;
-       protected $iconHtmlPath;
+       protected static $iconPath = null;
+       protected static $iconHtmlPath = null;
        
        protected $dateFormat;
        
@@ -538,8 +538,10 @@ class NagVisStatefulObject extends NagVisObject {
         */
        public function fetchIcon() {
                // Set the paths of this iconset
-               $this->iconPath = $this->CORE->getMainCfg()->getValue('paths', 
'icon');
-               $this->iconHtmlPath = 
$this->CORE->getMainCfg()->getValue('paths', 'htmlicon');
+               if(NagVisStatefulObject::$iconPath === null) {
+                       NagVisStatefulObject::$iconPath = 
$this->CORE->getMainCfg()->getValue('paths', 'icon');
+                       NagVisStatefulObject::$iconHtmlPath = 
$this->CORE->getMainCfg()->getValue('paths', 'htmlicon');
+               }
                
                // Read the filetype of the iconset
                $fileType = $this->CORE->getIconsetFiletype($this->iconset);
@@ -588,7 +590,7 @@ class NagVisStatefulObject extends NagVisObject {
                        }
                        
                        //Checks whether the needed file exists
-                       
if(@file_exists($this->CORE->getMainCfg()->getValue('paths', 'icon').$icon)) {
+                       if(@file_exists(NagVisStatefulObject::$iconPath . 
$icon)) {
                                $this->icon = $icon;
                        } else {
                                $this->icon = 
$this->iconset.'_error.'.$fileType;
diff --git a/share/server/core/classes/objects/NagVisStatelessObject.php 
b/share/server/core/classes/objects/NagVisStatelessObject.php
index 39146cf..a23d5ad 100644
--- a/share/server/core/classes/objects/NagVisStatelessObject.php
+++ b/share/server/core/classes/objects/NagVisStatelessObject.php
@@ -31,8 +31,8 @@ class NagVisStatelessObject extends NagVisObject {
        // "Global" Configuration variables for all stateless objects
        protected $label_show;
        
-       protected $iconPath;
-       protected $iconHtmlPath;
+       protected static $iconPath = null;
+       protected static $iconHtmlPath = null;
        
        /**
         * Class constructor


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins

Reply via email to