minor #21492 [DI] Deduplicate resources while adding them (nicolas-grekas)
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
-------
04853fc5c3
[DI] Deduplicate resource while adding them
This commit is contained in:
commit
29db096b0b
@ -202,7 +202,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
||||
*/
|
||||
public function getResources()
|
||||
{
|
||||
return array_unique($this->resources);
|
||||
return array_values($this->resources);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -218,7 +218,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->resources[] = $resource;
|
||||
$this->resources[(string) $resource] = $resource;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
Reference in New Issue
Block a user