8000 [DI] Reduce memory overhead of id normalization · symfony/symfony@1dd3285 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1dd3285

Browse files
[DI] Reduce memory overhead of id normalization
1 parent 9c0067b commit 1dd3285

18 files changed

+6
-72
lines changed

src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -938,17 +938,16 @@ public function isFrozen()
938938
*/
939939
private function addNormalizedIds()
940940
{
941-
if (!$normalizedIds = $this->container->getNormalizedIds()) {
942-
return '';
943-
}
944-
945-
$code = " \$this->normalizedIds = array(\n";
941+
$code = '';
942+
$normalizedIds = $this->container->getNormalizedIds();
946943
ksort($normalizedIds);
947944
foreach ($normalizedIds as $id => $normalizedId) {
948-
$code .= ' '.$this->export($id).' => '.$this->export($normalizedId).",\n";
945+
if ($this->container->has($normalizedId)) {
946+
$code .= ' '.$this->export($id).' => '.$this->export($normalizedId).",\n";
947+
}
949948
}
950949

951-
return $code." );\n";
950+
return $code ? " \$this->normalizedIds = array(\n".$code." );\n" : '';
952951
}
953952

954953
/**

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@ class Container extends AbstractContainer
2828
public function __construct()
2929
{
3030
$this->services = array();
31-
$this->normalizedIds = array(
32-
'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface',
33-
'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface',
34-
);
3531

3632
$this->aliases = array();
3733
}

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ class ProjectServiceContainer extends Container
2727
public function __construct()
2828
{
2929
$this->services = array();
30-
$this->normalizedIds = array(
31-
'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface',
32-
'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface',
33-
);
3430

3531
$this->aliases = array();
3632
}

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ public function __construct()
2929
$this->parameters = $this->getDefaultParameters();
3030

3131
$this->services = array();
32-
$this->normalizedIds = array(
33-
'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface',
34-
'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface',
35-
);
3632
$this->methodMap = array(
3733
'test' => 'getTestService',
3834
);

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ public function __construct()
3333
$this->parameters = $this->getDefaultParameters();
3434

3535
$this->services = array();
36-
$this->normalizedIds = array(
37-
'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface',
38-
'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface',
39-
);
4036
$this->methodMap = array(
4137
'test' => 'getTestService',
4238
);

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services13.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ class ProjectServiceContainer extends Container
2727
public function __construct()
2828
{
2929
$this->services = array();
30-
$this->normalizedIds = array(
31-
'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface',
32-
'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface',
33-
);
3430
$this->methodMap = array(
3531
'bar' => 'getBarService',
3632
);

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services19.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ class ProjectServiceContainer extends Container
2727
public function __construct()
2828
{
2929
$this->services = array();
30-
$this->normalizedIds = array(
31-
'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface',
32-
'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface',
33-
);
3430
$this->methodMap = array(
3531
'service_from_anonymous_factory' => 'getServiceFromAnonymousFactoryService',
3632
'service_with_method_call_and_factory' => 'getServiceWithMethodCallAndFactoryService',

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services24.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ class ProjectServiceContainer extends Container
2727
public function __construct()
2828
{
2929
$this->services = array();
30-
$this->normalizedIds = array(
31-
'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface',
32-
'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface',
33-
);
3430
$this->methodMap = array(
3531
'foo' => 'getFooService',
3632
);

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services26.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ public function __construct()
2929
$this->parameters = $this->getDefaultParameters();
3030

3131
$this->services = array();
32-
$this->normalizedIds = array(
33-
'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface',
34-
'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface',
35-
);
3632
$this->methodMap = array(
3733
'test' => 'getTestService',
3834
);

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services31.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ class ProjectServiceContainer extends Container
2727
public function __construct()
2828
{
2929
$this->services = array();
30-
$this->normalizedIds = array(
31-
'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface',
32-
'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface',
33-
);
3430
$this->methodMap = array(
3531
'bar' => 'getBarService',
3632
'foo' => 'getFooService',

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services32.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ class ProjectServiceContainer extends Container
2727
public function __construct()
2828
{
2929
$this->services = array();
30-
$this->normalizedIds = array(
31-
'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface',
32-
'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface',
33-
);
3430
$this->methodMap = array(
3531
'bar' => 'getBarService',
3632
'foo' => 'getFooService',

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services33.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ public function __construct()
2828
{
2929
$this->services = array();
3030
$this->normalizedIds = array(
31-
'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface',
32-
'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface',
3331
'symfony\\component\\dependencyinjection\\tests\\fixtures\\container33\\foo' => 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\Container33\\Foo',
3432
);
3533
$this->methodMap = array(

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ public function __construct()
2929
$this->parameters = $this->getDefaultParameters();
3030

3131
$this->services = array();
32-
$this->normalizedIds = array(
33-
'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface',
34-
'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface',
35-
);
3632

3733
$this->aliases = array();
3834
}

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ public function __construct()
2929
$this->parameters = $this->getDefaultParameters();
3030

3131
$this->services = array();
32-
$this->normalizedIds = array(
33-
'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface',
34-
'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface',
35-
);
3632
$this->methodMap = array(
3733
'bar' => 'getBarService',
3834
'baz' => 'getBazService',

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_dump_proxy_with_void_return_type.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ class ProjectServiceContainer extends Container
2727
public function __construct()
2828
{
2929
$this->services = array();
30-
$this->normalizedIds = array(
31-
'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface',
32-
'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface',
33-
);
3430
$this->methodMap = array(
3531
'bar' => 'getBarService',
3632
'foo' => 'getFooService',

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_locator.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ class ProjectServiceContainer extends Container
2727
public function __construct()
2828
{
2929
$this->services = array();
30-
$this->normalizedIds = array(
31-
'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface',
32-
'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface',
33-
);
3430
$this->methodMap = array(
3531
'bar_service' => 'getBarServiceService',
3632
'baz_service' => 'getBazServiceService',

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_private_frozen.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ class ProjectServiceContainer extends Container
2727
public function __construct()
2828
{
2929
$this->services = array();
30-
$this->normalizedIds = array(
31-
'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface',
32-
'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface',
33-
);
3430
$this->methodMap = array(
3531
'bar_service' => 'getBarServiceService',
3632
'baz_service' => 'getBazServiceService',

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_subscriber.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ public function __construct()
2929
$this->services = array();
3030
$this->normalizedIds = array(
3131
'autowired.symfony\\component\\dependencyinjection\\tests\\fixtures\\customdefinition' => 'autowired.Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\CustomDefinition',
32-
'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface',
33-
'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface',
34-
'symfony\\component\\dependencyinjection\\tests\\fixtures\\customdefinition' => 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\CustomDefinition',
3532
'symfony\\component\\dependencyinjection\\tests\\fixtures\\testservicesubscriber' => 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\TestServiceSubscriber',
3633
);
3734
$this->methodMap = array(

0 commit comments

Comments
 (0)
0