From 01e92e1761847e3ca0a2f4d9bbd641dee6224575 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Mon, 30 May 2022 23:31:59 +0300 Subject: [PATCH 1/3] Optimize array_merge --- src/CompositeContainer.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/CompositeContainer.php b/src/CompositeContainer.php index fe7d4153..e9e41a2f 100644 --- a/src/CompositeContainer.php +++ b/src/CompositeContainer.php @@ -65,11 +65,12 @@ public function get($id) } if ($container->has($id)) { /** @psalm-suppress MixedArgument Container::get() always return array for tag */ - $tags = array_merge($container->get($id), $tags); + array_unshift($tags, $container->get($id)); } } - return $tags; + /** @psalm-suppress MixedArgument Container::get() always return array for tag */ + return array_merge(...$tags); } foreach ($this->containers as $container) { From ee519c7fc109c60ec3e5f872e99a593b086deffa Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Mon, 30 May 2022 20:32:32 +0000 Subject: [PATCH 2/3] Apply fixes from StyleCI --- tests/Benchmark/ContainerBench.php | 32 +++++++++++++++--------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/Benchmark/ContainerBench.php b/tests/Benchmark/ContainerBench.php index 51252ab3..3805eeef 100644 --- a/tests/Benchmark/ContainerBench.php +++ b/tests/Benchmark/ContainerBench.php @@ -79,51 +79,51 @@ public function before(): void // We attach the dummy containers multiple times, to see what would happen if we have lots of them. $this->composite->attach( new Container( - ContainerConfig::create() + ContainerConfig::create() ->withDefinitions($definitions2) - ) + ) ); $this->composite->attach( new Container( - ContainerConfig::create() + ContainerConfig::create() ->withDefinitions($definitions3) - ) + ) ); $this->composite->attach( new Container( - ContainerConfig::create() + ContainerConfig::create() ->withDefinitions($definitions2) - ) + ) ); $this->composite->attach( new Container( - ContainerConfig::create() + ContainerConfig::create() ->withDefinitions($definitions3) - ) + ) ); $this->composite->attach( new Container( - ContainerConfig::create() + ContainerConfig::create() ->withDefinitions($definitions2) - ) + ) ); $this->composite->attach( new Container( - ContainerConfig::create() + ContainerConfig::create() ->withDefinitions($definitions3) - ) + ) ); $this->composite->attach( new Container( - ContainerConfig::create() + ContainerConfig::create() ->withDefinitions($definitions2) - ) + ) ); $this->composite->attach( new Container( - ContainerConfig::create() + ContainerConfig::create() ->withDefinitions($definitions3) - ) + ) ); } From 11e985a98142106629b66cf3388353050477b6eb Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Tue, 31 May 2022 11:47:33 +0300 Subject: [PATCH 3/3] Add changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 580cf99f..54e0cadc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## 1.0.3 under development -- no changes in this release. +- Enh #302: Improve performance collecting tags (samdark) ## 1.0.2 February 14, 2022