Skip to content

Commit

Permalink
[HttpFoundation] Avoid a few unnecessary str_replace() calls
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldaek committed May 5, 2013
1 parent f5e7f24 commit 997d549
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/Symfony/Component/HttpFoundation/RequestMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,20 +136,16 @@ public function matches(Request $request)
}

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

Expand Down

0 comments on commit 997d549

Please sign in to comment.