1
0
mirror of https://github.com/danog/amp.git synced 2024-11-26 20:15:00 +01:00

Micro-optimize interval = 0 if

This commit is contained in:
Niklas Keller 2017-05-23 20:17:34 +02:00
parent 38ef4d9ffa
commit ef6c2b10ee
2 changed files with 2 additions and 6 deletions

View File

@ -59,9 +59,7 @@ class EvDriver extends Driver {
if ($watcher->type & Watcher::DELAY) {
$this->cancel($watcher->id);
}
if ($watcher->type & Watcher::REPEAT && $watcher->value === 0) {
} elseif ($watcher->value === 0) {
// Disable and re-enable so it's not executed repeatedly in the same tick
// See https://github.com/amphp/amp/issues/131
$this->disable($watcher->id);

View File

@ -88,9 +88,7 @@ class UvDriver extends Driver {
if ($watcher->type & Watcher::DELAY) {
unset($this->events[$watcher->id], $this->watchers[(int) $event]); // Avoid call to uv_is_active().
$this->cancel($watcher->id); // Remove reference to watcher in parent.
}
if ($watcher->type & Watcher::REPEAT && $watcher->value === 0) {
} elseif ($watcher->value === 0) {
// Disable and re-enable so it's not executed repeatedly in the same tick
// See https://github.com/amphp/amp/issues/131
$this->disable($watcher->id);