From 321e2587b5835d638b4f54452f7d6b51965f814e Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Wed, 20 Dec 2023 16:25:58 +0100 Subject: [PATCH] PhotoMosaic: break out early in case of perfect score --- models/PhotoMosaic.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/models/PhotoMosaic.php b/models/PhotoMosaic.php index 71981f0..8326e1d 100644 --- a/models/PhotoMosaic.php +++ b/models/PhotoMosaic.php @@ -220,6 +220,10 @@ class PhotoMosaic { $score = $this->getScoreForRow($imageSelection, $requiredImageTypes); $fitnessScores[$layout] = [$score, $imageSelection]; + + // Perfect score? Bail out early + if ($score === count($requiredImageTypes)) + break; } }