Component/s: Standard Library
The refusal to pre-count elements of a `FlattenCollection` is based on reasoning about the performance of `flatMap`. But `flatMap`, when applied to collections of optionals, doesn't produce a LazyFlattenedCollection<…>, but a LazyMapCollection<LazyFilterCollection<…>>. We are not doing a similar thing for LazyFilterCollection.
The following demonstrates:
which currently generates Foo(i) 3 times for each i in 0..<10. If this FIXME were addressed it would go down to 2 times (once for counting), but if we take the option suggested in this bug, it would go down to 1 (at the cost of Array reallocations due to failing to pre-count, of course).