Permalink
Browse files

minor #21492 [DI] Deduplicate resources while adding them (nicolas-gr…

…ekas)

This PR was merged into the 3.3-dev branch.

Discussion
----------

[DI] Deduplicate resources while adding them

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Since the string cast of resources is already used to deduplicate them, let's do it earlier. This can only decrease memory usage.

Commits
-------

04853fc [DI] Deduplicate resource while adding them
  • Loading branch information...
2 parents b4ff1c8 + 04853fc commit 29db096b0ba6a19627e39f2ebe84ddd691a716c8 @fabpot fabpot committed Feb 1, 2017
Showing with 2 additions and 2 deletions.
  1. +2 −2 src/Symfony/Component/DependencyInjection/ContainerBuilder.php
@@ -202,7 +202,7 @@ public function hasExtension($name)
*/
public function getResources()
{
- return array_unique($this->resources);
+ return array_values($this->resources);
}
/**
@@ -218,7 +218,7 @@ public function addResource(ResourceInterface $resource)
return $this;
}
- $this->resources[] = $resource;
+ $this->resources[(string) $resource] = $resource;
return $this;
}

0 comments on commit 29db096

Please sign in to comment.