Parcourir la source

Performance optimization

walkor il y a 1 an
Parent
commit
1d25e3f402
2 fichiers modifiés avec 6 ajouts et 6 suppressions
  1. 3 3
      src/Events/Event.php
  2. 3 3
      src/Events/Select.php

+ 3 - 3
src/Events/Event.php

@@ -140,7 +140,7 @@ final class Event implements EventInterface
     {
         $className = $this->eventClassName;
         $timerId = $this->timerId++;
-        $event = new $className($this->eventBase, -1, $className::TIMEOUT | $className::PERSIST, fn () => $this->safeCall($func, $args));
+        $event = new $className($this->eventBase, -1, $className::TIMEOUT | $className::PERSIST, $func);
         if (!$event->addTimer($interval)) {
             throw new \RuntimeException("Event::addTimer($interval) failed");
         }
@@ -155,7 +155,7 @@ final class Event implements EventInterface
     {
         $className = $this->eventClassName;
         $fdKey = (int)$stream;
-        $event = new $className($this->eventBase, $stream, $className::READ | $className::PERSIST, fn () => $this->safeCall($func, [$stream]));
+        $event = new $className($this->eventBase, $stream, $className::READ | $className::PERSIST, $func);
         if ($event->add()) {
             $this->readEvents[$fdKey] = $event;
         }
@@ -182,7 +182,7 @@ final class Event implements EventInterface
     {
         $className = $this->eventClassName;
         $fdKey = (int)$stream;
-        $event = new $className($this->eventBase, $stream, $className::WRITE | $className::PERSIST, fn () => $this->safeCall($func, [$stream]));
+        $event = new $className($this->eventBase, $stream, $className::WRITE | $className::PERSIST, $func);
         if ($event->add()) {
             $this->writeEvents[$fdKey] = $event;
         }

+ 3 - 3
src/Events/Select.php

@@ -381,21 +381,21 @@ final class Select implements EventInterface
             foreach ($read as $fd) {
                 $fdKey = (int)$fd;
                 if (isset($this->readEvents[$fdKey])) {
-                    $this->safeCall($this->readEvents[$fdKey], [$fd]);
+                    $this->readEvents[$fdKey]($fd);
                 }
             }
 
             foreach ($write as $fd) {
                 $fdKey = (int)$fd;
                 if (isset($this->writeEvents[$fdKey])) {
-                    $this->safeCall($this->writeEvents[$fdKey], [$fd]);
+                    $this->writeEvents[$fdKey]($fd);
                 }
             }
 
             foreach ($except as $fd) {
                 $fdKey = (int)$fd;
                 if (isset($this->exceptEvents[$fdKey])) {
-                    $this->safeCall($this->exceptEvents[$fdKey], [$fd]);
+                    $this->exceptEvents[$fdKey]($fd);
                 }
             }