[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:
parent
997d549846
commit
ea633f5787
@ -35,6 +35,7 @@ class RouterListener implements EventSubscriberInterface
|
|||||||
private $matcher;
|
private $matcher;
|
||||||
private $context;
|
private $context;
|
||||||
private $logger;
|
private $logger;
|
||||||
|
private $request;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
@ -72,9 +73,10 @@ class RouterListener implements EventSubscriberInterface
|
|||||||
*/
|
*/
|
||||||
public function setRequest(Request $request = null)
|
public function setRequest(Request $request = null)
|
||||||
{
|
{
|
||||||
if (null !== $request) {
|
if (null !== $request && $this->request !== $request) {
|
||||||
$this->context->fromRequest($request);
|
$this->context->fromRequest($request);
|
||||||
}
|
}
|
||||||
|
$this->request = $request;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onKernelRequest(GetResponseEvent $event)
|
public function onKernelRequest(GetResponseEvent $event)
|
||||||
|
Reference in New Issue
Block a user