Skip to content

Commit

Permalink
minor #21492 [DI] Deduplicate resources while adding them (nicolas-gr…
Browse files Browse the repository at this point in the history
…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
fabpot committed Feb 1, 2017
2 parents b4ff1c8 + 04853fc commit 29db096
Showing 1 changed file with 2 additions and 2 deletions.
Expand Up @@ -202,7 +202,7 @@ public function hasExtension($name)
*/
public function getResources()
{
return array_unique($this->resources);
return array_values($this->resources);
}

/**
Expand All @@ -218,7 +218,7 @@ public function addResource(ResourceInterface $resource)
return $this;
}

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

return $this;
}
Expand Down

0 comments on commit 29db096

Please sign in to comment.