Skip to content

Commit

Permalink
[HttpKernel] Avoid updating the context if the request did not change
Browse files Browse the repository at this point in the history
Due to the BC $this->setRequest() call in the onKernelRequest method, the
request is set twice every time in Symfony, and RequestContext::fromRequest
takes 1ms to run here so if we can skip one call it is a win.
  • Loading branch information
Seldaek committed May 5, 2013
1 parent 997d549 commit ea633f5
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class RouterListener implements EventSubscriberInterface
private $matcher;
private $context;
private $logger;
private $request;

/**
* Constructor.
Expand Down Expand Up @@ -72,9 +73,10 @@ public function __construct($matcher, RequestContext $context = null, LoggerInte
*/
public function setRequest(Request $request = null)
{
if (null !== $request) {
if (null !== $request && $this->request !== $request) {
$this->context->fromRequest($request);
}
$this->request = $request;
}

public function onKernelRequest(GetResponseEvent $event)
Expand Down

0 comments on commit ea633f5

Please sign in to comment.