From 997d5498467698a57ff7af8fab2dd5a7737bc60e Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sat, 4 May 2013 20:49:25 +0200 Subject: [PATCH] [HttpFoundation] Avoid a few unnecessary str_replace() calls --- .../Component/HttpFoundation/RequestMatcher.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/Symfony/Component/HttpFoundation/RequestMatcher.php b/src/Symfony/Component/HttpFoundation/RequestMatcher.php index b4bc880d4a..769ca66ecd 100644 --- a/src/Symfony/Component/HttpFoundation/RequestMatcher.php +++ b/src/Symfony/Component/HttpFoundation/RequestMatcher.php @@ -136,20 +136,16 @@ class RequestMatcher implements RequestMatcherInterface } foreach ($this->attributes as $key => $pattern) { - if (!preg_match('#'.str_replace('#', '\\#', $pattern).'#', $request->attributes->get($key))) { + if (!preg_match('{'.$pattern.'}', $request->attributes->get($key))) { return false; } } - if (null !== $this->path) { - $path = str_replace('#', '\\#', $this->path); - - if (!preg_match('#'.$path.'#', rawurldecode($request->getPathInfo()))) { - return false; - } + if (null !== $this->path && !preg_match('{'.$this->path.'}', rawurldecode($request->getPathInfo()))) { + return false; } - if (null !== $this->host && !preg_match('#'.str_replace('#', '\\#', $this->host).'#i', $request->getHost())) { + if (null !== $this->host && !preg_match('{'.$this->host.'}i', $request->getHost())) { return false; }