merged branch Partugal/patch-guesser-perfomance (PR #5298)
Commits
-------
630d16b
small optimization
Discussion
----------
[Form] Guesser perfomance
speedup depends on count of guesses
on my tests is 2,4 and 6 x faster for 5, 10 and 20 guesses
This commit is contained in:
commit
ef29276c3a
@ -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