I avoided allocating useless arrays for the result
Your benchmark is completely unrealistic, chalk & cheese comparison, and thus totally broken.
- keys & values used in void context:>
- "In particular, calling keys() in void context resets the iterator with no other overhead."
- "(In particular, calling values() in void context resets the iterator with no other overhead.)"
- Whilst grep in a void context probably avoid generating the return list; it doesn't stop it from iterating the entire input list.
Benchmark code that doesn't actually produce the required result is broken. And broken, is just broken; of no value at all.
Obviously vec scales badly the sparser the distribution of values become...