Browse Source

flipped conditions to gain performance

Mark Magyar 2 years ago
parent
commit
e921a04b91
4 changed files with 4 additions and 4 deletions
  1. 1 1
      src/Connection/TcpConnection.php
  2. 1 1
      src/Protocols/Websocket.php
  3. 1 1
      src/Protocols/Ws.php
  4. 1 1
      src/Worker.php

+ 1 - 1
src/Connection/TcpConnection.php

@@ -939,7 +939,7 @@ class TcpConnection extends ConnectionInterface implements JsonSerializable
      */
     protected function checkBufferWillFull(): void
     {
-        if ($this->maxSendBufferSize <= strlen($this->sendBuffer) && $this->onBufferFull) {
+        if ($this->onBufferFull && $this->maxSendBufferSize <= strlen($this->sendBuffer)) {
             try {
                 ($this->onBufferFull)($this);
             } catch (Throwable $e) {

+ 1 - 1
src/Protocols/Websocket.php

@@ -285,7 +285,7 @@ class Websocket
             }
             $connection->context->tmpWebsocketData .= $encodeBuffer;
             // Check buffer is full.
-            if ($connection->maxSendBufferSize <= strlen($connection->context->tmpWebsocketData) && $connection->onBufferFull) {
+            if ($connection->onBufferFull && $connection->maxSendBufferSize <= strlen($connection->context->tmpWebsocketData)) {
                 try {
                     ($connection->onBufferFull)($connection);
                 } catch (Throwable $e) {

+ 1 - 1
src/Protocols/Ws.php

@@ -279,7 +279,7 @@ class Ws
             }
             $connection->context->tmpWebsocketData = $connection->context->tmpWebsocketData . $frame;
             // Check buffer is full.
-            if ($connection->maxSendBufferSize <= strlen($connection->context->tmpWebsocketData) && $connection->onBufferFull) {
+            if ($connection->onBufferFull && $connection->maxSendBufferSize <= strlen($connection->context->tmpWebsocketData)) {
                 try {
                     ($connection->onBufferFull)($connection);
                 } catch (Throwable $e) {

+ 1 - 1
src/Worker.php

@@ -1400,7 +1400,7 @@ class Worker
     protected static function forkWorkersForWindows(): void
     {
         $files = static::getStartFilesForWindows();
-        if (in_array('-q', static::getArgv()) || count($files) === 1) {
+        if (count($files) === 1 || in_array('-q', static::getArgv())) {
             if (count(static::$workers) > 1) {
                 static::safeEcho("@@@ Error: multi workers init in one php file are not support @@@\r\n");
                 static::safeEcho("@@@ See https://www.workerman.net/doc/workerman/faq/multi-woker-for-windows.html @@@\r\n");