In practice, the return value of NextCandidate is always either an
integer or nil. Change the return type from (interface{}, candidateType)
to (int) to avoid allocations on this path.
These changes eliminate the vast majority of the allocations during
matching and remove the need for type assertions in callers of
NextCandidate. This results in about a 20% speedup across all
benchmarks.
In practice, the return value of NextCandidate is always either an integer or nil. Change the return type from (interface{}, candidateType) to (int) to avoid allocations on this path.
These changes eliminate the vast majority of the allocations during matching and remove the need for type assertions in callers of NextCandidate. This results in about a 20% speedup across all benchmarks.