From c6c062ae24cf03490a7171d2b3a5a8bbc6edc2c4 Mon Sep 17 00:00:00 2001 From: Greg Bowler Date: Thu, 29 Jun 2023 13:50:11 +0100 Subject: [PATCH] test: reduce computational complexity --- src/Promise.php | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/Promise.php b/src/Promise.php index e041512..11db947 100644 --- a/src/Promise.php +++ b/src/Promise.php @@ -132,12 +132,6 @@ private function tryComplete():void { } private function complete():void { - $this->sortChain(); - $this->handleChain(); - $this->completed = true; - } - - private function sortChain():void { usort( $this->chain, function(Chainable $a, Chainable $b) { @@ -151,9 +145,6 @@ function(Chainable $a, Chainable $b) { return 0; } ); - } - - private function handleChain():void { $handledRejections = []; $emptyChain = empty($this->chain); @@ -178,6 +169,8 @@ private function handleChain():void { } $this->handleCatches($originalChain, $emptyChain, $handledRejections); + + $this->completed = true; } private function getNextChainItem():?Chainable {