Michael Long
Jul 22, 2023

--

You start out by saying "let's write our own filter method".... but then don't don't use the array .filter { } function.

Why?

One thing that .filter does is preallocate a result array that doesn't need to be continually resized and reallocated during execution. That makes a big difference, especially in large result sets.

But your later comments are correct. Avoid premature optimization unless and until performance measurements indicate that they're needed.

--

--

Michael Long
Michael Long

Written by Michael Long

I write about Apple, Swift, and SwiftUI in particular, and technology in general. I'm also a Lead iOS Engineer at InRhythm, a modern digital consulting firm.

No responses yet