Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 29db096

Browse files
committed
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 ------- 04853fc [DI] Deduplicate resource while adding them
2 parents b4ff1c8 + 04853fc commit 29db096

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Symfony/Component/DependencyInjection/ContainerBuilder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ public function hasExtension($name)
202202
*/
203203
public function getResources()
204204
{
205-
return array_unique($this->resources);
205+
return array_values($this->resources);
206206
}
207207

208208
/**
@@ -218,7 +218,7 @@ public function addResource(ResourceInterface $resource)
218218
return $this;
219219
}
220220

221-
$this->resources[] = $resource;
221+
$this->resources[(string) $resource] = $resource;
222222

223223
return $this;
224224
}

0 commit comments

Comments
 (0)