Improved issue 93, memory usage.

I have been doing tracing of the memory usage using xdebug, now I am
normally below 15MB for the linux kernel instead of 35MB. Please test.
dev
Loic d'Anterroches 2009-01-06 22:56:02 +01:00
parent a30a62d48f
commit a6c42120d8
1 changed files with 4 additions and 4 deletions

View File

@ -115,7 +115,7 @@ class IDF_Scm_Git
// As we are limiting to a given folder, we need to find // As we are limiting to a given folder, we need to find
// the tree corresponding to this folder. // the tree corresponding to this folder.
$found = false; $found = false;
foreach ($this->getTreeInfo($co->tree) as $file) { foreach ($this->getTreeInfo($co->tree, true, $folder) as $file) {
if ($file->type == 'tree' and $file->file == $folder) { if ($file->type == 'tree' and $file->file == $folder) {
$found = true; $found = true;
$tree = $file->hash; $tree = $file->hash;
@ -166,16 +166,16 @@ class IDF_Scm_Git
* @param bool Do we recurse in subtrees (true) * @param bool Do we recurse in subtrees (true)
* @return array Array of file information. * @return array Array of file information.
*/ */
public function getTreeInfo($tree, $recurse=true) public function getTreeInfo($tree, $recurse=true, $folder='')
{ {
if ('tree' != $this->testHash($tree)) { if ('tree' != $this->testHash($tree)) {
throw new Exception(sprintf(__('Not a valid tree: %s.'), $tree)); throw new Exception(sprintf(__('Not a valid tree: %s.'), $tree));
} }
$cmd_tmpl = 'GIT_DIR=%s git ls-tree%s -t -l %s'; $cmd_tmpl = 'GIT_DIR=%s git ls-tree%s -t -l %s %s';
$cmd = sprintf($cmd_tmpl, $cmd = sprintf($cmd_tmpl,
escapeshellarg($this->repo), escapeshellarg($this->repo),
($recurse) ? ' -r' : '', ($recurse) ? ' -r' : '',
escapeshellarg($tree)); escapeshellarg($tree), escapeshellarg($folder));
$out = array(); $out = array();
$res = array(); $res = array();
IDF_Scm::exec($cmd, $out); IDF_Scm::exec($cmd, $out);