Przeglądaj źródła

Small performance

Joanhey 6 lat temu
rodzic
commit
41398f9a4f
3 zmienionych plików z 8 dodań i 8 usunięć
  1. 1 1
      Events/Ev.php
  2. 5 5
      Events/Swoole.php
  3. 2 2
      Worker.php

+ 1 - 1
Events/Ev.php

@@ -72,7 +72,7 @@ class Ev implements EventInterface
                 return true;
             case self::EV_TIMER:
             case self::EV_TIMER_ONCE:
-                $repeat                             = $flag == self::EV_TIMER_ONCE ? 0 : $fd;
+                $repeat                             = $flag === self::EV_TIMER_ONCE ? 0 : $fd;
                 $param                              = array($func, (array)$args, $flag, $fd, self::$_timerId);
                 $event                              = new \EvTimer($fd, $repeat, array($this, 'timerCallback'), $param);
                 $this->_eventTimer[self::$_timerId] = $event;

+ 5 - 5
Events/Swoole.php

@@ -56,7 +56,7 @@ class Swoole implements EventInterface
                 return $res;
             case self::EV_TIMER:
             case self::EV_TIMER_ONCE:
-                $method = self::EV_TIMER == $flag ? 'tick' : 'after';
+                $method = self::EV_TIMER === $flag ? 'tick' : 'after';
                 if ($this->mapId > PHP_INT_MAX) {
                     $this->mapId = 0;
                 }
@@ -74,7 +74,7 @@ class Swoole implements EventInterface
                             }
                         }
                     });
-                if ($flag == self::EV_TIMER_ONCE) {
+                if ($flag === self::EV_TIMER_ONCE) {
                     $this->_timerOnceMap[$mapId] = $timer_id;
                     $this->_timer[$timer_id] = $mapId;
                 } else {
@@ -85,7 +85,7 @@ class Swoole implements EventInterface
             case self::EV_WRITE:
                 $fd_key = (int) $fd;
                 if (! isset($this->_fd[$fd_key])) {
-                    if ($flag == self::EV_READ) {
+                    if ($flag === self::EV_READ) {
                         $res = Event::add($fd, $func, null, SWOOLE_EVENT_READ);
                         $fd_type = SWOOLE_EVENT_READ;
                     } else {
@@ -98,7 +98,7 @@ class Swoole implements EventInterface
                 } else {
                     $fd_val = $this->_fd[$fd_key];
                     $res = true;
-                    if ($flag == self::EV_READ) {
+                    if ($flag === self::EV_READ) {
                         if (($fd_val & SWOOLE_EVENT_READ) !== SWOOLE_EVENT_READ) {
                             $res = Event::set($fd, $func, null,
                                 SWOOLE_EVENT_READ | SWOOLE_EVENT_WRITE);
@@ -147,7 +147,7 @@ class Swoole implements EventInterface
                 $fd_key = (int) $fd;
                 if (isset($this->_fd[$fd_key])) {
                     $fd_val = $this->_fd[$fd_key];
-                    if ($flag == self::EV_READ) {
+                    if ($flag === self::EV_READ) {
                         $flag_remove = ~ SWOOLE_EVENT_READ;
                     } else {
                         $flag_remove = ~ SWOOLE_EVENT_WRITE;

+ 2 - 2
Worker.php

@@ -735,7 +735,7 @@ class Worker
         foreach(static::getUiColumns() as $column_name => $prop){
             $key = '_max' . \ucfirst(\strtolower($column_name)) . 'NameLength';
             //just keep compatible with listen name 
-            $column_name == 'socket' && $column_name = 'listen';
+            $column_name === 'socket' && $column_name = 'listen';
             $title.= "<w>{$column_name}</w>"  .  \str_pad('', static::$$key + static::UI_SAFE_LENGTH - \strlen($column_name));
         }
         $title && static::safeEcho($title . PHP_EOL);
@@ -2482,7 +2482,7 @@ class Worker
                     if(\method_exists($parser,'input')){
                         while($recv_buffer !== ''){
                             $len = $parser::input($recv_buffer, $connection);
-                            if($len == 0)
+                            if($len === 0)
                                 return true;
                             $package = \substr($recv_buffer,0,$len);
                             $recv_buffer = \substr($recv_buffer,$len);