Skip to content

Commit

Permalink
[Performance] Use spl_object_id() when possible
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Aug 30, 2023
1 parent 6e7e587 commit a0ec75e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Timer/Timers.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function getTime()

public function add(TimerInterface $timer)
{
$id = \spl_object_hash($timer);
$id = \PHP_VERSION_ID < 70200 ? \spl_object_hash($timer) : \spl_object_id($timer);
$this->timers[$id] = $timer;
$this->schedule[$id] = $timer->getInterval() + $this->updateTime();
$this->sorted = false;
Expand All @@ -51,7 +51,7 @@ public function contains(TimerInterface $timer)

public function cancel(TimerInterface $timer)
{
$id = \spl_object_hash($timer);
$id = \PHP_VERSION_ID < 70200 ? \spl_object_hash($timer) : \spl_object_id($timer);
unset($this->timers[$id], $this->schedule[$id]);
}

Expand Down

0 comments on commit a0ec75e

Please sign in to comment.