I decided to learn how to make Swift go fast
I optimised my code with pointers and a lot more, inlining certain functions and so on, to the point where it's barely more readable than C and worse than Rust; the performance is not bad but unfortunately is still many times slower.
Profiling the executable tells me that a lot of time is spent appending to arrays. The length of every array in my code is known ahead of time, no time is spent copying the arrays to double their size. I don't know what makes it so slow.
There seems to be an issue with String and Character types, even not doing anything my code can barely output 2mb/s
Even trying to join strings and characters together seems to decrease performance 20 times compared to just using print in a loop
I thought it could be because I'm converting [Character] to String but after rewriting everything with just Strings it's exactly the same :(
Am I doing something wrong or is the String type just really not optimised for speed at all