Changeset 613

Show
Ignore:
Timestamp:
04/24/07 16:15:39 (1 year ago)
Author:
mikey
Message:

the need for speed: reduced amount of realpath() calls

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/config/php/config-dist.php

    r566 r613  
    55class stubConfig 
    66{ 
     7    /** 
     8     * path to libary files 
     9     * 
     10     * @var  string 
     11     */ 
     12    private static $libPath    = null; 
     13    /** 
     14     * path to source files 
     15     * 
     16     * @var  string 
     17     */ 
     18    private static $sourcePath = null; 
     19    /** 
     20     * path to log files 
     21     * 
     22     * @var  string 
     23     */ 
     24    private static $logPath    = null; 
     25    /** 
     26     * path to cache files 
     27     * 
     28     * @var  string 
     29     */ 
     30    private static $cachePath  = null; 
     31    /** 
     32     * path to config files 
     33     * 
     34     * @var  string 
     35     */ 
     36    private static $configPath = null; 
     37 
    738    /** 
    839     * this method should return the path to the lib directory 
     
    1445    public static function getLibPath() 
    1546    { 
    16         return realpath(dirname(__FILE__) . '/../../lib'); 
     47        if (null == self::$libPath) { 
     48            self::$libPath = realpath(dirname(__FILE__) . '/../../lib'); 
     49        } 
     50         
     51        return self::$libPath; 
    1752    } 
    1853 
     
    2661    public static function getSourcePath() 
    2762    { 
    28         return realpath(dirname(__FILE__) . '/../../src/main'); 
     63        if (null == self::$sourcePath) { 
     64            self::$sourcePath = realpath(dirname(__FILE__) . '/../../src/main'); 
     65        } 
     66         
     67        return self::$sourcePath; 
    2968    } 
    3069 
     
    3877    public static function getLogPath() 
    3978    { 
    40         return realpath(dirname(__FILE__) . '/../../log'); 
     79        if (null == self::$logPath) { 
     80            self::$logPath = realpath(dirname(__FILE__) . '/../../log') . '/{Y}/{M}'; 
     81        } 
     82         
     83        return self::$logPath; 
    4184    } 
    4285 
     
    5093    public static function getCachePath() 
    5194    { 
    52         return realpath(dirname(__FILE__) . '/../../cache'); 
     95        if (null == self::$cachePath) { 
     96            self::$cachePath = realpath(dirname(__FILE__) . '/../../cache'); 
     97        } 
     98         
     99        return self::$cachePath; 
    53100    } 
    54101 
     
    62109    public static function getConfigPath() 
    63110    { 
    64         return realpath(dirname(__FILE__) . '/../'); 
     111        if (null == self::$configPath) { 
     112            self::$configPath = realpath(dirname(__FILE__) . '/../'); 
     113        } 
     114         
     115        return self::$configPath; 
    65116    } 
    66117 
  • trunk/config/php/config.php

    r573 r613  
    55class stubConfig 
    66{ 
     7    /** 
     8     * path to libary files 
     9     * 
     10     * @var  string 
     11     */ 
     12    private static $libPath    = null; 
     13    /** 
     14     * path to source files 
     15     * 
     16     * @var  string 
     17     */ 
     18    private static $sourcePath = null; 
     19    /** 
     20     * path to log files 
     21     * 
     22     * @var  string 
     23     */ 
     24    private static $logPath    = null; 
     25    /** 
     26     * path to cache files 
     27     * 
     28     * @var  string 
     29     */ 
     30    private static $cachePath  = null; 
     31    /** 
     32     * path to config files 
     33     * 
     34     * @var  string 
     35     */ 
     36    private static $configPath = null; 
     37 
    738    /** 
    839     * this method should return the path to the lib directory 
     
    1445    public static function getLibPath() 
    1546    { 
    16         return realpath(dirname(__FILE__) . '/../../lib'); 
     47        if (null == self::$libPath) { 
     48            self::$libPath = realpath(dirname(__FILE__) . '/../../lib'); 
     49        } 
     50         
     51        return self::$libPath; 
    1752    } 
    1853 
     
    2661    public static function getSourcePath() 
    2762    { 
    28         return realpath(dirname(__FILE__) . '/../../src/main'); 
     63        if (null == self::$sourcePath) { 
     64            self::$sourcePath = realpath(dirname(__FILE__) . '/../../src/main'); 
     65        } 
     66         
     67        return self::$sourcePath; 
    2968    } 
    3069 
     
    3877    public static function getLogPath() 
    3978    { 
    40         return realpath(dirname(__FILE__) . '/../../log'); 
     79        if (null == self::$logPath) { 
     80            self::$logPath = realpath(dirname(__FILE__) . '/../../log'); 
     81        } 
     82         
     83        return self::$logPath; 
    4184    } 
    4285 
     
    5093    public static function getCachePath() 
    5194    { 
    52         return realpath(dirname(__FILE__) . '/../../cache'); 
     95        if (null == self::$cachePath) { 
     96            self::$cachePath = realpath(dirname(__FILE__) . '/../../cache'); 
     97        } 
     98         
     99        return self::$cachePath; 
    53100    } 
    54101 
     
    62109    public static function getConfigPath() 
    63110    { 
    64         return realpath(dirname(__FILE__) . '/../'); 
     111        if (null == self::$configPath) { 
     112            self::$configPath = realpath(dirname(__FILE__) . '/../'); 
     113        } 
     114         
     115        return self::$configPath; 
    65116    } 
    66117 
  • trunk/src/main/php/net/stubbles/star/StarClassRegistry.php

    r553 r613  
    4848    { 
    4949        self::$libPathes[$libPath] = $recursive; 
    50         self::$initDone = false; 
     50        self::$initDone            = false; 
    5151    } 
    5252 
     
    5959    public static function getFileForClass($fqClassName) 
    6060    { 
    61         self::init(); 
     61        if (false === self::$initDone) { 
     62            self::init(); 
     63        } 
     64         
    6265        if (isset(self::$classes[$fqClassName]) == true) { 
    6366            return self::$classes[$fqClassName]; 
     
    7578    public static function getUriForClass($fqClassName) 
    7679    { 
    77         self::init(); 
     80        if (false === self::$initDone) { 
     81            self::init(); 
     82        } 
     83         
    7884        if (isset(self::$classes[$fqClassName]) == true) { 
    7985            return 'star://' . self::$classes[$fqClassName] . '?' . $fqClassName; 
     
    9197    public static function getUrisForResource($resource) 
    9298    { 
    93         self::init(); 
     99        if (false === self::$initDone) { 
     100            self::init(); 
     101        } 
     102         
    94103        $uris = array(); 
    95104        foreach (self::$files as $file => $contents) { 
     
    113122    public static function getClassNamesFromFile($file) 
    114123    { 
    115         self::init(); 
     124        if (false === self::$initDone) { 
     125            self::init(); 
     126        } 
     127         
    116128        if (isset(self::$files[$file]) == true) { 
    117129            return self::$files[$file]; 
  • trunk/src/main/php/net/stubbles/util/stubFactory.php

    r475 r613  
    2222     */ 
    2323    private static $resourcePath = null; 
     24    /** 
     25     * switch whether to use star files or not 
     26     * 
     27     * @var  bool 
     28     */ 
     29    private static $useStar      = null; 
    2430     
    2531    /** 
     
    2834    public static function __static() 
    2935    { 
    30         if (basename(__FILE__) != __CLASS__ . '.php') { 
    31             self::$resourcePath = realpath(str_replace('star://', '', dirname(__FILE__)) . '/../src/main/resources') . DIRECTORY_SEPARATOR; 
     36        self::$resourcePath = stubConfig::getSourcePath() . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR; 
     37        if (stubConfig::useStar() == true && class_exists('StarClassRegistry', false) == true) { 
     38            self::$useStar = true; 
    3239        } else { 
    33             self::$resourcePath = realpath(dirname(__FILE__) . '/../../../../resources') . DIRECTORY_SEPARATOR
     40            self::$useStar = false
    3441        } 
    3542    } 
     
    4350    public static function getResourceURIs($fileName) 
    4451    { 
    45         if (stubConfig::useStar() == true && class_exists('StarClassRegistry', false) == true) { 
     52        if (true == self::$useStar) { 
    4653            $uris = StarClassRegistry::getUrisForResource($fileName); 
    4754        } else {