From 8f53d1ca7626dc77e05a42f3cad049b02f2450da Mon Sep 17 00:00:00 2001 From: Korvin Szanto Date: Fri, 31 Oct 2014 09:35:48 -0700 Subject: [PATCH 1/3] Make `\Request::get` more performant. --- src/Symfony/Component/HttpFoundation/Request.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpFoundation/Request.php b/src/Symfony/Component/HttpFoundation/Request.php index a542cf46720e1..1a80ec0ef88d1 100644 --- a/src/Symfony/Component/HttpFoundation/Request.php +++ b/src/Symfony/Component/HttpFoundation/Request.php @@ -723,7 +723,17 @@ public static function getHttpMethodParameterOverride() */ public function get($key, $default = null, $deep = false) { - return $this->query->get($key, $this->attributes->get($key, $this->request->get($key, $default, $deep), $deep), $deep); + $result = $this->query($key, $this, $deep); + if ($result === $this) { + $result = $this->attributes->get($key, $this, $deep); + } + if ($result === $this) { + $result = $this->request->get($key, $this, $deep); + } + if ($result === $this) { + return $default; + } + return $result; } /** From d1f36d681eae7e1cef45279c727795426f7e75cd Mon Sep 17 00:00:00 2001 From: Korvin Szanto Date: Fri, 31 Oct 2014 09:41:06 -0700 Subject: [PATCH 2/3] Fix typo --- src/Symfony/Component/HttpFoundation/Request.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpFoundation/Request.php b/src/Symfony/Component/HttpFoundation/Request.php index 1a80ec0ef88d1..a209b421a087e 100644 --- a/src/Symfony/Component/HttpFoundation/Request.php +++ b/src/Symfony/Component/HttpFoundation/Request.php @@ -723,7 +723,7 @@ public static function getHttpMethodParameterOverride() */ public function get($key, $default = null, $deep = false) { - $result = $this->query($key, $this, $deep); + $result = $this->query->get($key, $this, $deep); if ($result === $this) { $result = $this->attributes->get($key, $this, $deep); } From b59b99b93a4af2981ebd389e42e2598cb6378f8d Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Fri, 21 Nov 2014 15:29:33 +0100 Subject: [PATCH 3/3] reformat code as suggested by @fabpot --- .../Component/HttpFoundation/Request.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/Symfony/Component/HttpFoundation/Request.php b/src/Symfony/Component/HttpFoundation/Request.php index a209b421a087e..9d2d546bcc57c 100644 --- a/src/Symfony/Component/HttpFoundation/Request.php +++ b/src/Symfony/Component/HttpFoundation/Request.php @@ -723,17 +723,19 @@ public static function getHttpMethodParameterOverride() */ public function get($key, $default = null, $deep = false) { - $result = $this->query->get($key, $this, $deep); - if ($result === $this) { - $result = $this->attributes->get($key, $this, $deep); + if ($this !== $result = $this->query->get($key, $this, $deep)) { + return $result; } - if ($result === $this) { - $result = $this->request->get($key, $this, $deep); + + if ($this !== $result = $this->attributes->get($key, $this, $deep)) { + return $result; } - if ($result === $this) { - return $default; + + if ($this !== $result = $this->request->get($key, $this, $deep)) { + return $result; } - return $result; + + return $default; } /**