minor #22480 [DI] Reduce memory overhead of id normalization (nicolas-grekas)
This PR was merged into the 3.3-dev branch.
Discussion
----------
[DI] Reduce memory overhead of id normalization
| Q | A
| ------------- | ---
| Branch? | 3.3
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | no
| Fixed tickets | -
| License | MIT
| Doc PR | -
Commits
-------
1dd3285c91
[DI] Reduce memory overhead of id normalization
This commit is contained in:
commit
f9bb4dccb8
@ -938,17 +938,16 @@ EOF;
|
||||
*/
|
||||
private function addNormalizedIds()
|
||||
{
|
||||
if (!$normalizedIds = $this->container->getNormalizedIds()) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$code = " \$this->normalizedIds = array(\n";
|
||||
$code = '';
|
||||
$normalizedIds = $this->container->getNormalizedIds();
|
||||
ksort($normalizedIds);
|
||||
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()
|
||||
{
|
||||
$this->services = array();
|
||||
$this->normalizedIds = array(
|
||||
'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface',
|
||||
'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface',
|
||||
);
|
||||
|
||||
$this->aliases = array();
|
||||
}
|
||||
|
@ -27,10 +27,6 @@ class ProjectServiceContainer extends Container
|
||||
public function __construct()
|
||||
{
|
||||
$this->services = array();
|
||||
$this->normalizedIds = array(
|
||||
'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface',
|
||||
'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface',
|
||||
);
|
||||
|
||||
$this->aliases = array();
|
||||
}
|
||||
|
@ -29,10 +29,6 @@ class ProjectServiceContainer extends Container
|
||||
$this->parameters = $this->getDefaultParameters();
|
||||
|
||||
$this->services = array();
|
||||
$this->normalizedIds = array(
|
||||
'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface',
|
||||
'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface',
|
||||
);
|
||||
$this->methodMap = array(
|
||||
'test' => 'getTestService',
|
||||
);
|
||||
|
@ -33,10 +33,6 @@ class ProjectServiceContainer extends Container
|
||||
$this->parameters = $this->getDefaultParameters();
|
||||
|
||||
$this->services = array();
|
||||
$this->normalizedIds = array(
|
||||
'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface',
|
||||
'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface',
|
||||
);
|
||||
$this->methodMap = array(
|
||||
'test' => 'getTestService',
|
||||
);
|
||||
|
@ -27,10 +27,6 @@ class ProjectServiceContainer extends Container
|
||||
public function __construct()
|
||||
{
|
||||
$this->services = array();
|
||||
$this->normalizedIds = array(
|
||||
'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface',
|
||||
'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface',
|
||||
);
|
||||
$this->methodMap = array(
|
||||
'bar' => 'getBarService',
|
||||
);
|
||||
|
@ -27,10 +27,6 @@ class ProjectServiceContainer extends Container
|
||||
public function __construct()
|
||||
{
|
||||
$this->services = array();
|
||||
$this->normalizedIds = array(
|
||||
'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface',
|
||||
'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface',
|
||||
);
|
||||
$this->methodMap = array(
|
||||
'service_from_anonymous_factory' => 'getServiceFromAnonymousFactoryService',
|
||||
'service_with_method_call_and_factory' => 'getServiceWithMethodCallAndFactoryService',
|
||||
|
@ -27,10 +27,6 @@ class ProjectServiceContainer extends Container
|
||||
public function __construct()
|
||||
{
|
||||
$this->services = array();
|
||||
$this->normalizedIds = array(
|
||||
'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface',
|
||||
'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface',
|
||||
);
|
||||
$this->methodMap = array(
|
||||
'foo' => 'getFooService',
|
||||
);
|
||||
|
@ -29,10 +29,6 @@ class ProjectServiceContainer extends Container
|
||||
$this->parameters = $this->getDefaultParameters();
|
||||
|
||||
$this->services = array();
|
||||
$this->normalizedIds = array(
|
||||
'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface',
|
||||
'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface',
|
||||
);
|
||||
$this->methodMap = array(
|
||||
'test' => 'getTestService',
|
||||
);
|
||||
|
@ -27,10 +27,6 @@ class ProjectServiceContainer extends Container
|
||||
public function __construct()
|
||||
{
|
||||
$this->services = array();
|
||||
$this->normalizedIds = array(
|
||||
'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface',
|
||||
'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface',
|
||||
);
|
||||
$this->methodMap = array(
|
||||
'bar' => 'getBarService',
|
||||
'foo' => 'getFooService',
|
||||
|
@ -27,10 +27,6 @@ class ProjectServiceContainer extends Container
|
||||
public function __construct()
|
||||
{
|
||||
$this->services = array();
|
||||
$this->normalizedIds = array(
|
||||
'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface',
|
||||
'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface',
|
||||
);
|
||||
$this->methodMap = array(
|
||||
'bar' => 'getBarService',
|
||||
'foo' => 'getFooService',
|
||||
|
@ -28,8 +28,6 @@ class ProjectServiceContainer extends Container
|
||||
{
|
||||
$this->services = 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',
|
||||
);
|
||||
$this->methodMap = array(
|
||||
|
@ -29,10 +29,6 @@ class ProjectServiceContainer extends Container
|
||||
$this->parameters = $this->getDefaultParameters();
|
||||
|
||||
$this->services = array();
|
||||
$this->normalizedIds = array(
|
||||
'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface',
|
||||
'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface',
|
||||
);
|
||||
|
||||
$this->aliases = array();
|
||||
}
|
||||
|
@ -29,10 +29,6 @@ class ProjectServiceContainer extends Container
|
||||
$this->parameters = $this->getDefaultParameters();
|
||||
|
||||
$this->services = array();
|
||||
$this->normalizedIds = array(
|
||||
'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface',
|
||||
'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface',
|
||||
);
|
||||
$this->methodMap = array(
|
||||
'bar' => 'getBarService',
|
||||
'baz' => 'getBazService',
|
||||
|
@ -27,10 +27,6 @@ class ProjectServiceContainer extends Container
|
||||
public function __construct()
|
||||
{
|
||||
$this->services = array();
|
||||
$this->normalizedIds = array(
|
||||
'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface',
|
||||
'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface',
|
||||
);
|
||||
$this->methodMap = array(
|
||||
'bar' => 'getBarService',
|
||||
'foo' => 'getFooService',
|
||||
|
@ -27,10 +27,6 @@ class ProjectServiceContainer extends Container
|
||||
public function __construct()
|
||||
{
|
||||
$this->services = array();
|
||||
$this->normalizedIds = array(
|
||||
'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface',
|
||||
'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface',
|
||||
);
|
||||
$this->methodMap = array(
|
||||
'bar_service' => 'getBarServiceService',
|
||||
'baz_service' => 'getBazServiceService',
|
||||
|
@ -27,10 +27,6 @@ class ProjectServiceContainer extends Container
|
||||
public function __construct()
|
||||
{
|
||||
$this->services = array();
|
||||
$this->normalizedIds = array(
|
||||
'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface',
|
||||
'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface',
|
||||
);
|
||||
$this->methodMap = array(
|
||||
'bar_service' => 'getBarServiceService',
|
||||
'baz_service' => 'getBazServiceService',
|
||||
|
@ -29,9 +29,6 @@ class ProjectServiceContainer extends Container
|
||||
$this->services = array();
|
||||
$this->normalizedIds = array(
|
||||
'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',
|
||||
);
|
||||
$this->methodMap = array(
|
||||
|
Reference in New Issue
Block a user