From d07ae2654fa0abb723a1720bbd6044aa0022d748 Mon Sep 17 00:00:00 2001 From: maks feltrin Date: Fri, 27 May 2016 23:17:48 +0200 Subject: [PATCH 1/4] use sm3 configure when possible to prevent any performance overhead. (same reasons for https://github.com/zendframework/zend-form/pull/77) --- src/View/HelperConfig.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/View/HelperConfig.php b/src/View/HelperConfig.php index 107a62cd..a8e76311 100644 --- a/src/View/HelperConfig.php +++ b/src/View/HelperConfig.php @@ -74,12 +74,17 @@ class HelperConfig implements ConfigInterface */ public function configureServiceManager(ServiceManager $serviceManager) { - foreach ($this->factories as $name => $factory) { - $serviceManager->setFactory($name, $factory); - } - foreach ($this->aliases as $alias => $target) { - $serviceManager->setAlias($alias, $target); + if (method_exists($serviceManager, 'configure')) { + $serviceManager->configure($this->toArray()); + } else { + foreach ($this->factories as $name => $factory) { + $serviceManager->setFactory($name, $factory); + } + foreach ($this->aliases as $alias => $target) { + $serviceManager->setAlias($alias, $target); + } } + return $serviceManager; } From 741157d118032ce3041d7fcb3e345467e4aca029 Mon Sep 17 00:00:00 2001 From: maks feltrin Date: Fri, 27 May 2016 23:22:06 +0200 Subject: [PATCH 2/4] fix copy-n-paste trailing whitespace --- src/View/HelperConfig.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/View/HelperConfig.php b/src/View/HelperConfig.php index a8e76311..737f5e43 100644 --- a/src/View/HelperConfig.php +++ b/src/View/HelperConfig.php @@ -76,7 +76,7 @@ public function configureServiceManager(ServiceManager $serviceManager) { if (method_exists($serviceManager, 'configure')) { $serviceManager->configure($this->toArray()); - } else { + } else { foreach ($this->factories as $name => $factory) { $serviceManager->setFactory($name, $factory); } From 6909d27c1dcab435df40f26062f9df6c7ac44bcf Mon Sep 17 00:00:00 2001 From: maks feltrin Date: Mon, 6 Jun 2016 10:35:22 +0200 Subject: [PATCH 3/4] replace else with early return --- src/View/HelperConfig.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/View/HelperConfig.php b/src/View/HelperConfig.php index 737f5e43..4cb9ea6d 100644 --- a/src/View/HelperConfig.php +++ b/src/View/HelperConfig.php @@ -76,13 +76,14 @@ public function configureServiceManager(ServiceManager $serviceManager) { if (method_exists($serviceManager, 'configure')) { $serviceManager->configure($this->toArray()); - } else { - foreach ($this->factories as $name => $factory) { - $serviceManager->setFactory($name, $factory); - } - foreach ($this->aliases as $alias => $target) { - $serviceManager->setAlias($alias, $target); - } + return $serviceManager; + } + + foreach ($this->factories as $name => $factory) { + $serviceManager->setFactory($name, $factory); + } + foreach ($this->aliases as $alias => $target) { + $serviceManager->setAlias($alias, $target); } return $serviceManager; From ffb036ccfdcdd7f2a3a2bf55fa3d38f6dbbcc065 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Tue, 7 Jun 2016 16:08:25 -0500 Subject: [PATCH 4/4] Added CHANGELOG for #47 --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 906607a4..a48367ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,9 @@ All notable changes to this project will be documented in this file, in reverse provided, but validate based on the uppercased country value. This ensures the same validation behavior, and prevents the value from being transformed, potentially breaking later retrieval. +- [#47](https://github.com/zendframework/zend-i18n/pull/47) provides a + performance improvement to the `Zend\I18n\View\HelperConfig` implementation + when operating under zend-servicemanager v3. ## 2.7.2 - 2016-04-18