Commit d46cc599 authored by Guilherme Blanco's avatar Guilherme Blanco

Merge pull request #160 from dtrethewey/migration-related-performance-improvements

Prevent repeat instantiation of reserved keywords class
parents e5377453 b595b76e
...@@ -106,6 +106,13 @@ abstract class AbstractPlatform ...@@ -106,6 +106,13 @@ abstract class AbstractPlatform
*/ */
protected $_eventManager; protected $_eventManager;
/**
* Holds the KeywordList instance for the current platform.
*
* @var Doctrine\DBAL\Platforms\Keywords\KeywordList
*/
protected $_keywords;
/** /**
* Constructor. * Constructor.
*/ */
...@@ -2682,11 +2689,20 @@ abstract class AbstractPlatform ...@@ -2682,11 +2689,20 @@ abstract class AbstractPlatform
*/ */
final public function getReservedKeywordsList() final public function getReservedKeywordsList()
{ {
// Check for an existing instantiation of the keywords class.
if ($this->keywords) {
return $this->keywords;
}
$class = $this->getReservedKeywordsClass(); $class = $this->getReservedKeywordsClass();
$keywords = new $class; $keywords = new $class;
if ( ! $keywords instanceof \Doctrine\DBAL\Platforms\Keywords\KeywordList) { if ( ! $keywords instanceof \Doctrine\DBAL\Platforms\Keywords\KeywordList) {
throw DBALException::notSupported(__METHOD__); throw DBALException::notSupported(__METHOD__);
} }
// Store the instance so it doesn't need to be generated on every request.
$this->keywords = $keywords;
return $keywords; return $keywords;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment