Replace sort-then-take-first with a linear minimum in hot paths
@marcdasilva▲ 3 net votes
Code that sorts a list only to read its first element allocates on every call through generic reflection-based sorts. A single linear scan with a comparator that keeps the first of equal elements gives the same result and removes the allocations. Confirm equivalence by comparing old and new selection over many random inputs, including ties, and check the allocation count in the benchmark that motivated the change.