Merge pull request #2203 from camspiers/config-memory

Improve memory performance when generating config static and class caches
This commit is contained in:
Ingo Schommer 2013-07-08 06:35:31 -07:00
commit 3bfb82d25f
4 changed files with 32 additions and 15 deletions

View File

@ -273,6 +273,15 @@ class SS_ClassManifest {
return $modules;
}
/**
* Used to set up files that we want to exclude from parsing for performance reasons.
*/
protected function setDefaults()
{
$this->classes['sstemplateparser'] = FRAMEWORK_PATH.'/view/SSTemplateParser.php';
$this->classes['sstemplateparseexception'] = FRAMEWORK_PATH.'/view/SSTemplateParser.php';
}
/**
* Completely regenerates the manifest file.
*
@ -289,10 +298,12 @@ class SS_ClassManifest {
$this->$reset = array();
}
$this->setDefaults();
$finder = new ManifestFileFinder();
$finder->setOptions(array(
'name_regex' => '/^(_config.php|[^_].*\.php)$/',
'ignore_files' => array('index.php', 'main.php', 'cli-script.php'),
'ignore_files' => array('index.php', 'main.php', 'cli-script.php', 'SSTemplateParser.php'),
'ignore_tests' => !$this->tests,
'file_callback' => array($this, 'handleFile'),
'dir_callback' => array($this, 'handleDir')

View File

@ -100,7 +100,7 @@ class SS_ConfigStaticManifest {
$finder = new ManifestFileFinder();
$finder->setOptions(array(
'name_regex' => '/^([^_].*\.php)$/',
'ignore_files' => array('index.php', 'main.php', 'cli-script.php'),
'ignore_files' => array('index.php', 'main.php', 'cli-script.php', 'SSTemplateParser.php'),
'ignore_tests' => !$this->tests,
'file_callback' => array($this, 'handleFile')
));

View File

@ -36,17 +36,20 @@ class ClassManifestTest extends SapphireTest {
public function testGetClasses() {
$expect = array(
'classb' => "{$this->base}/module/classes/ClassB.php",
'classa' => "{$this->base}/module/classes/ClassA.php",
'classb' => "{$this->base}/module/classes/ClassB.php",
'classc' => "{$this->base}/module/classes/ClassC.php",
'classd' => "{$this->base}/module/classes/ClassD.php"
'classd' => "{$this->base}/module/classes/ClassD.php",
'sstemplateparser' => FRAMEWORK_PATH."/view/SSTemplateParser.php",
'sstemplateparseexception' => FRAMEWORK_PATH."/view/SSTemplateParser.php"
);
$this->assertEquals($expect, $this->manifest->getClasses());
}
public function testGetClassNames() {
$this->assertEquals(
array('classa', 'classb', 'classc', 'classd'),
array('sstemplateparser', 'sstemplateparseexception', 'classa', 'classb', 'classc', 'classd'),
$this->manifest->getClassNames());
}

View File

@ -41,7 +41,9 @@ class NamespacedClassManifestTest extends SapphireTest {
'silverstripe\test\classe' => "{$this->base}/module/classes/ClassE.php",
'silverstripe\test\classf' => "{$this->base}/module/classes/ClassF.php",
'silverstripe\test\classg' => "{$this->base}/module/classes/ClassG.php",
'silverstripe\test\classh' => "{$this->base}/module/classes/ClassH.php"
'silverstripe\test\classh' => "{$this->base}/module/classes/ClassH.php",
'sstemplateparser' => FRAMEWORK_PATH."/view/SSTemplateParser.php",
'sstemplateparseexception' => FRAMEWORK_PATH."/view/SSTemplateParser.php"
);
$this->assertEquals($expect, $this->manifest->getClasses());
@ -49,9 +51,10 @@ class NamespacedClassManifestTest extends SapphireTest {
public function testGetClassNames() {
$this->assertEquals(
array('silverstripe\test\classa', 'silverstripe\test\classb', 'silverstripe\test\classc',
'silverstripe\test\classd', 'silverstripe\test\classe', 'silverstripe\test\classf',
'silverstripe\test\classg', 'silverstripe\test\classh'),
array('sstemplateparser', 'sstemplateparseexception', 'silverstripe\test\classa',
'silverstripe\test\classb', 'silverstripe\test\classc', 'silverstripe\test\classd',
'silverstripe\test\classe', 'silverstripe\test\classf', 'silverstripe\test\classg',
'silverstripe\test\classh'),
$this->manifest->getClassNames());
}