mirror of
https://github.com/danog/amp.git
synced 2024-11-30 04:29:08 +01:00
Use simple assignment if queue is empty
The common case is for the queue to be empty at the start of the tick, so a call to array_merge() can be avoided in most cases.
This commit is contained in:
parent
628d8cbab1
commit
fdeb427717
@ -91,7 +91,11 @@ abstract class Driver {
|
||||
* Executes a single tick of the event loop.
|
||||
*/
|
||||
private function tick() {
|
||||
$this->deferQueue = \array_merge($this->deferQueue, $this->nextTickQueue);
|
||||
if (empty($this->deferQueue)) {
|
||||
$this->deferQueue = $this->nextTickQueue;
|
||||
} else {
|
||||
$this->deferQueue = \array_merge($this->deferQueue, $this->nextTickQueue);
|
||||
}
|
||||
$this->nextTickQueue = [];
|
||||
|
||||
$this->activate($this->enableQueue);
|
||||
|
Loading…
Reference in New Issue
Block a user