Use comprehension instead of filter + collect

Suggested by @gavinking on IRC.