Skip to content

Commit

Permalink
Merge pull request #160 from dtrethewey/migration-related-performance…
Browse files Browse the repository at this point in the history
…-improvements

Prevent repeat instantiation of reserved keywords class
  • Loading branch information
guilhermeblanco committed Jun 7, 2012
2 parents e537745 + b595b76 commit d46cc59
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ abstract class AbstractPlatform
*/
protected $_eventManager;

/**
* Holds the KeywordList instance for the current platform.
*
* @var Doctrine\DBAL\Platforms\Keywords\KeywordList
*/
protected $_keywords;

/**
* Constructor.
*/
Expand Down Expand Up @@ -2682,11 +2689,20 @@ public function rollbackSavePoint($savepoint)
*/
final public function getReservedKeywordsList()
{
// Check for an existing instantiation of the keywords class.
if ($this->keywords) {
return $this->keywords;
}

$class = $this->getReservedKeywordsClass();
$keywords = new $class;
if ( ! $keywords instanceof \Doctrine\DBAL\Platforms\Keywords\KeywordList) {
throw DBALException::notSupported(__METHOD__);
}

// Store the instance so it doesn't need to be generated on every request.
$this->keywords = $keywords;

return $keywords;
}

Expand Down

0 comments on commit d46cc59

Please sign in to comment.