Convert Results to Array


Hello, I’m investigating some memory/performance issues on my application and a specific usage with large amount of data.
I’m trying to understand where the bottleneck is and thought about something that is largely done in the project right now.

In several places on the app, we are converting a Results<T> to a [T] with Array(results).
Is this a bad pattern? Should be avoided?

I noticed that Results implements LazyCollectionProtocol protocol, which allow it to be passed as the argument for the array constructor, but I don’t know what the implementation will do, will this continue being lazy as Results is?

Thank you in advance.


Arrays in swift are not lazy, so converting results to array will take up a lot more memory and should be avoided where possible, i.e. when loading results into a tableview, or other places where the user does not see all the data at once.