Confused by String Iteration performance

It's possible I can fix this properly at some point for String(contentsOfFile: …, encoding: .utf8), but the non-encoding taking version will be much trickier (it does a bunch of work to try to guess the encoding that would be delicate to replicate in the overlay).

So my suggestion would be regardless of what workarounds you use (e.g. fileText.makeContiguousUTF8()), switch to the encoding-taking version of the initializer as well.

3 Likes