small optimization
This commit is contained in:
parent
7fe18d13a0
commit
630d16b8c7
@ -79,11 +79,17 @@ abstract class Guess
|
||||
*/
|
||||
public static function getBestGuess(array $guesses)
|
||||
{
|
||||
usort($guesses, function ($a, $b) {
|
||||
return $b->getConfidence() - $a->getConfidence();
|
||||
});
|
||||
$result = null;
|
||||
$maxConfidence = -1;
|
||||
|
||||
return count($guesses) > 0 ? $guesses[0] : null;
|
||||
foreach ($guesses as $guess) {
|
||||
if ($maxConfidence < $confidence = $guess->getConfidence()) {
|
||||
$maxConfidence = $confidence;
|
||||
$result = $guess;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user