8000 minor #21492 [DI] Deduplicate resources while adding them (nicolas-gr… · symfony/dependency-injection@03ae38c · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 03ae38c

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 ------- 04853fc5c3 [DI] Deduplicate resource while adding them
2 parents 81c72bf + dd01ab4 commit 03ae38c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

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);
< 8C75 /td>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)
0