From: hickert Date: Mon, 15 Oct 2007 12:14:18 +0000 (+0000) Subject: PPD manager speed improvements. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=e6934ea3ce185f857eb6c9f1c499f3e5e2d57854;p=gosa.git PPD manager speed improvements. Only reload ppds that have been modified. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@7551 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/include/class_ppdManager.inc b/include/class_ppdManager.inc index 7e416556d..a9dfd1a7f 100644 --- a/include/class_ppdManager.inc +++ b/include/class_ppdManager.inc @@ -4,6 +4,7 @@ class ppdManager { var $path= ""; var $cachedList= array(); + var $timestamps = array(); function ppdManager($path) { @@ -288,6 +289,16 @@ class ppdManager $model= ""; $manufacturer= ""; + + /* Only parse complete PPD file again, if it was changed */ + $modified = filemtime($ppdFile); + if(isset($this->cachedList[$ppdFile]) && isset($this->timestamps[$ppdFile]) && $modified == $this->timestamps[$ppdFile]){ + return($this->cachedList[$ppdFile]); + } + + /* Remember modified timestamp, to speed up next request */ + $this->timestamps[$ppdFile] = filemtime($ppdFile); + $fh= fopen ($ppdFile, 'r'); while ((!feof($fh))&&($fh)) { @@ -329,10 +340,11 @@ class ppdManager $list= $this->findPPD($this->path); /* Load descriptive informations to build final printer list */ - $this->cachedList= array(); + $new = array(); foreach ($list as $ppdFile){ - $this->cachedList[$ppdFile]= $this->loadDescription($ppdFile); + $new[$ppdFile] = $this->loadDescription($ppdFile); } + $this->cachedList= $new ; }