[DI] Reduce memory overhead of id normalization
This commit is contained in:
parent
9c0067b19f
commit
1dd3285c91
@ -938,17 +938,16 @@ EOF;
|
|||||||
*/
|
*/
|
||||||
private function addNormalizedIds()
|
private function addNormalizedIds()
|
||||||
{
|
{
|
||||||
if (!$normalizedIds = $this->container->getNormalizedIds()) {
|
$code = '';
|
||||||
return '';
|
$normalizedIds = $this->container->getNormalizedIds();
|
||||||
}
|
|
||||||
|
|
||||||
$code = " \$this->normalizedIds = array(\n";
|
|
||||||
ksort($normalizedIds);
|
ksort($normalizedIds);
|
||||||
foreach ($normalizedIds as $id => $normalizedId) {
|
foreach ($normalizedIds as $id => $normalizedId) {
|
||||||
$code .= ' '.$this->export($id).' => '.$this->export($normalizedId).",\n";
|
if ($this->container->has($normalizedId)) {
|
||||||
|
$code .= ' '.$this->export($id).' => '.$this->export($normalizedId).",\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $code." );\n";
|
return $code ? " \$this->normalizedIds = array(\n".$code." );\n" : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,10 +28,6 @@ class Container extends AbstractContainer
|
|||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->services = array();
|
$this->services = array();
|
||||||
$this->normalizedIds = array(
|
|
||||||
'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface',
|
|
||||||
'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface',
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->aliases = array();
|
$this->aliases = array();
|
||||||
}
|
}
|
||||||
|
@ -27,10 +27,6 @@ class ProjectServiceContainer extends Container
|
|||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->services = array();
|
$this->services = array();
|
||||||
$this->normalizedIds = array(
|
|
||||||
'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface',
|
|
||||||
'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface',
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->aliases = array();
|
$this->aliases = array();
|
||||||
}
|
}
|
||||||
|
@ -29,10 +29,6 @@ class ProjectServiceContainer extends Container
|
|||||||
$this->parameters = $this->getDefaultParameters();
|
$this->parameters = $this->getDefaultParameters();
|
||||||
|
|
||||||
$this->services = array();
|
$this->services = array();
|
||||||
$this->normalizedIds = array(
|
|
||||||
'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface',
|
|
||||||
'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface',
|
|
||||||
);
|
|
||||||
$this->methodMap = array(
|
$this->methodMap = array(
|
||||||
'test' => 'getTestService',
|
'test' => 'getTestService',
|
||||||
);
|
);
|
||||||
|
@ -33,10 +33,6 @@ class ProjectServiceContainer extends Container
|
|||||||
$this->parameters = $this->getDefaultParameters();
|
$this->parameters = $this->getDefaultParameters();
|
||||||
|
|
||||||
$this->services = array();
|
$this->services = array();
|
||||||
$this->normalizedIds = array(
|
|
||||||
'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface',
|
|
||||||
'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface',
|
|
||||||
);
|
|
||||||
$this->methodMap = array(
|
$this->methodMap = array(
|
||||||
'test' => 'getTestService',
|
'test' => 'getTestService',
|
||||||
);
|
);
|
||||||
|
@ -27,10 +27,6 @@ class ProjectServiceContainer extends Container
|
|||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->services = array();
|
$this->services = array();
|
||||||
$this->normalizedIds = array(
|
|
||||||
'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface',
|
|
||||||
'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface',
|
|
||||||
);
|
|
||||||
$this->methodMap = array(
|
$this->methodMap = array(
|
||||||
'bar' => 'getBarService',
|
'bar' => 'getBarService',
|
||||||
);
|
);
|
||||||
|
@ -27,10 +27,6 @@ class ProjectServiceContainer extends Container
|
|||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->services = array();
|
$this->services = array();
|
||||||
$this->normalizedIds = array(
|
|
||||||
'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface',
|
|
||||||
'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface',
|
|
||||||
);
|
|
||||||
$this->methodMap = array(
|
$this->methodMap = array(
|
||||||
'service_from_anonymous_factory' => 'getServiceFromAnonymousFactoryService',
|
'service_from_anonymous_factory' => 'getServiceFromAnonymousFactoryService',
|
||||||
'service_with_method_call_and_factory' => 'getServiceWithMethodCallAndFactoryService',
|
'service_with_method_call_and_factory' => 'getServiceWithMethodCallAndFactoryService',
|
||||||
|
@ -27,10 +27,6 @@ class ProjectServiceContainer extends Container
|
|||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->services = array();
|
$this->services = array();
|
||||||
$this->normalizedIds = array(
|
|
||||||
'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface',
|
|
||||||
'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface',
|
|
||||||
);
|
|
||||||
$this->methodMap = array(
|
$this->methodMap = array(
|
||||||
'foo' => 'getFooService',
|
'foo' => 'getFooService',
|
||||||
);
|
);
|
||||||
|
@ -29,10 +29,6 @@ class ProjectServiceContainer extends Container
|
|||||||
$this->parameters = $this->getDefaultParameters();
|
$this->parameters = $this->getDefaultParameters();
|
||||||
|
|
||||||
$this->services = array();
|
$this->services = array();
|
||||||
$this->normalizedIds = array(
|
|
||||||
'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface',
|
|
||||||
'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface',
|
|
||||||
);
|
|
||||||
$this->methodMap = array(
|
$this->methodMap = array(
|
||||||
'test' => 'getTestService',
|
'test' => 'getTestService',
|
||||||
);
|
);
|
||||||
|
@ -27,10 +27,6 @@ class ProjectServiceContainer extends Container
|
|||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->services = array();
|
$this->services = array();
|
||||||
$this->normalizedIds = array(
|
|
||||||
'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface',
|
|
||||||
'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface',
|
|
||||||
);
|
|
||||||
$this->methodMap = array(
|
$this->methodMap = array(
|
||||||
'bar' => 'getBarService',
|
'bar' => 'getBarService',
|
||||||
'foo' => 'getFooService',
|
'foo' => 'getFooService',
|
||||||
|
@ -27,10 +27,6 @@ class ProjectServiceContainer extends Container
|
|||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->services = array();
|
$this->services = array();
|
||||||
$this->normalizedIds = array(
|
|
||||||
'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface',
|
|
||||||
'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface',
|
|
||||||
);
|
|
||||||
$this->methodMap = array(
|
$this->methodMap = array(
|
||||||
'bar' => 'getBarService',
|
'bar' => 'getBarService',
|
||||||
'foo' => 'getFooService',
|
'foo' => 'getFooService',
|
||||||
|
@ -28,8 +28,6 @@ class ProjectServiceContainer extends Container
|
|||||||
{
|
{
|
||||||
$this->services = array();
|
$this->services = array();
|
||||||
$this->normalizedIds = array(
|
$this->normalizedIds = array(
|
||||||
'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface',
|
|
||||||
'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface',
|
|
||||||
'symfony\\component\\dependencyinjection\\tests\\fixtures\\container33\\foo' => 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\Container33\\Foo',
|
'symfony\\component\\dependencyinjection\\tests\\fixtures\\container33\\foo' => 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\Container33\\Foo',
|
||||||
);
|
);
|
||||||
$this->methodMap = array(
|
$this->methodMap = array(
|
||||||
|
@ -29,10 +29,6 @@ class ProjectServiceContainer extends Container
|
|||||||
$this->parameters = $this->getDefaultParameters();
|
$this->parameters = $this->getDefaultParameters();
|
||||||
|
|
||||||
$this->services = array();
|
$this->services = array();
|
||||||
$this->normalizedIds = array(
|
|
||||||
'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface',
|
|
||||||
'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface',
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->aliases = array();
|
$this->aliases = array();
|
||||||
}
|
}
|
||||||
|
@ -29,10 +29,6 @@ class ProjectServiceContainer extends Container
|
|||||||
$this->parameters = $this->getDefaultParameters();
|
$this->parameters = $this->getDefaultParameters();
|
||||||
|
|
||||||
$this->services = array();
|
$this->services = array();
|
||||||
$this->normalizedIds = array(
|
|
||||||
'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface',
|
|
||||||
'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface',
|
|
||||||
);
|
|
||||||
$this->methodMap = array(
|
$this->methodMap = array(
|
||||||
'bar' => 'getBarService',
|
'bar' => 'getBarService',
|
||||||
'baz' => 'getBazService',
|
'baz' => 'getBazService',
|
||||||
|
@ -27,10 +27,6 @@ class ProjectServiceContainer extends Container
|
|||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->services = array();
|
$this->services = array();
|
||||||
$this->normalizedIds = array(
|
|
||||||
'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface',
|
|
||||||
'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface',
|
|
||||||
);
|
|
||||||
$this->methodMap = array(
|
$this->methodMap = array(
|
||||||
'bar' => 'getBarService',
|
'bar' => 'getBarService',
|
||||||
'foo' => 'getFooService',
|
'foo' => 'getFooService',
|
||||||
|
@ -27,10 +27,6 @@ class ProjectServiceContainer extends Container
|
|||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->services = array();
|
$this->services = array();
|
||||||
$this->normalizedIds = array(
|
|
||||||
'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface',
|
|
||||||
'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface',
|
|
||||||
);
|
|
||||||
$this->methodMap = array(
|
$this->methodMap = array(
|
||||||
'bar_service' => 'getBarServiceService',
|
'bar_service' => 'getBarServiceService',
|
||||||
'baz_service' => 'getBazServiceService',
|
'baz_service' => 'getBazServiceService',
|
||||||
|
@ -27,10 +27,6 @@ class ProjectServiceContainer extends Container
|
|||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->services = array();
|
$this->services = array();
|
||||||
$this->normalizedIds = array(
|
|
||||||
'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface',
|
|
||||||
'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface',
|
|
||||||
);
|
|
||||||
$this->methodMap = array(
|
$this->methodMap = array(
|
||||||
'bar_service' => 'getBarServiceService',
|
'bar_service' => 'getBarServiceService',
|
||||||
'baz_service' => 'getBazServiceService',
|
'baz_service' => 'getBazServiceService',
|
||||||
|
@ -29,9 +29,6 @@ class ProjectServiceContainer extends Container
|
|||||||
$this->services = array();
|
$this->services = array();
|
||||||
$this->normalizedIds = array(
|
$this->normalizedIds = array(
|
||||||
'autowired.symfony\\component\\dependencyinjection\\tests\\fixtures\\customdefinition' => 'autowired.Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\CustomDefinition',
|
'autowired.symfony\\component\\dependencyinjection\\tests\\fixtures\\customdefinition' => 'autowired.Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\CustomDefinition',
|
||||||
'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface',
|
|
||||||
'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface',
|
|
||||||
'symfony\\component\\dependencyinjection\\tests\\fixtures\\customdefinition' => 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\CustomDefinition',
|
|
||||||
'symfony\\component\\dependencyinjection\\tests\\fixtures\\testservicesubscriber' => 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\TestServiceSubscriber',
|
'symfony\\component\\dependencyinjection\\tests\\fixtures\\testservicesubscriber' => 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\TestServiceSubscriber',
|
||||||
);
|
);
|
||||||
$this->methodMap = array(
|
$this->methodMap = array(
|
||||||
|
Reference in New Issue
Block a user