From fabc09a16bf32fca9a42bb04df042a516de5d520 Mon Sep 17 00:00:00 2001 From: Mark <14284867+xHeaven@users.noreply.github.com> Date: Sun, 29 Dec 2024 21:22:12 +0100 Subject: [PATCH] Revert unwanted if-else simplification --- src/Concerns/ParallelCommand.php | 18 +++++++----------- src/Listeners/QueueableListener.php | 12 ++++++------ 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/src/Concerns/ParallelCommand.php b/src/Concerns/ParallelCommand.php index e743d8c1..0eaa0fbe 100644 --- a/src/Concerns/ParallelCommand.php +++ b/src/Concerns/ParallelCommand.php @@ -48,17 +48,15 @@ trait ParallelCommand if ($pid === -1) { return -1; - } - - if ($pid) { + } elseif ($pid) { // Parent return $pid; + } else { + // Child + DB::reconnect(); + + exit($this->childHandle(...$args) ? 0 : 1); } - - // Child - DB::reconnect(); - - exit($this->childHandle(...$args) ? 0 : 1); } protected function sysctlGetLogicalCoreCount(bool $darwin): int @@ -72,9 +70,7 @@ trait ParallelCommand // perflevel0 refers to P-cores on M-series, and the entire CPU on Intel Macs if ($darwin && $ffi->sysctlbyname('hw.perflevel0.logicalcpu', FFI::addr($cores), FFI::addr($size), null, 0) === 0) { return $cores->cdata; - } - - if ($darwin) { + } elseif ($darwin) { // Reset the size in case the pointer got written to (likely shouldn't happen) $size->cdata = FFI::sizeof($cores); } diff --git a/src/Listeners/QueueableListener.php b/src/Listeners/QueueableListener.php index 22ad1f1f..f486873d 100644 --- a/src/Listeners/QueueableListener.php +++ b/src/Listeners/QueueableListener.php @@ -17,12 +17,12 @@ abstract class QueueableListener implements ShouldQueue { if (static::$shouldQueue) { return true; + } else { + // The listener is not queued so we manually + // pass the event to the handle() method. + $this->handle($event); + + return false; } - - // The listener is not queued so we manually - // pass the event to the handle() method. - $this->handle($event); - - return false; } }