[HttpKernel] Avoid updating the context if the request did not change

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.
This commit is contained in:
Jordi Boggiano 2013-05-04 20:51:13 +02:00
parent 997d549846
commit ea633f5787

View File

@ -35,6 +35,7 @@ class RouterListener implements EventSubscriberInterface
private $matcher;
private $context;
private $logger;
private $request;
/**
* Constructor.
@ -72,9 +73,10 @@ class RouterListener implements EventSubscriberInterface
*/
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)