In cases like this where you know that once the predicate returns false for an element, it won't ever return true for a later element, you can replace filter with takeWhile, which stops taking elements as soon as the predicate returns false for the first time.