Skip to content

Commit af160e2

Browse files
committed
minor #36724 [HttpFoundation] fix perf of ResponseHeaderBag::initDate() (nicolas-grekas)
This PR was merged into the 5.1-dev branch. Discussion ---------- [HttpFoundation] fix perf of ResponseHeaderBag::initDate() | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - This change alone makes a skeleton hello world go from 1600 req/s to 1800 req/s on my machine (with preloading enabled to remove the cost of the autoloader). Another discovery by [![image](https://user-images.githubusercontent.com/243674/81168746-e00cf280-8f97-11ea-9f18-7e14e84b2828.png)](https://blackfire.io/) Commits ------- 1294cb5 [HttpFoundation] fix perf of ResponseHeaderBag::initDate()
2 parents 78df4ca + 1294cb5 commit af160e2

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,6 @@ protected function computeCacheControlValue()
286286

287287
private function initDate(): void
288288
{
289-
$now = \DateTime::createFromFormat('U', time());
290-
$now->setTimezone(new \DateTimeZone('UTC'));
291-
$this->set('Date', $now->format('D, d M Y H:i:s').' GMT');
289+
$this->set('Date', gmdate('D, d M Y H:i:s').' GMT');
292290
}
293291
}

0 commit comments

Comments
 (0)