[HttpFoundation] Avoid a few unnecessary str_replace() calls

This commit is contained in:
Jordi Boggiano 2013-05-04 20:49:25 +02:00
parent f5e7f24819
commit 997d549846

View File

@ -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;
}