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.