But this raises more questions, because what I changed is the test code generation. I'm now generating a million different strings instead of adding the same string a million times (note the \(i) at the end of the string):
func generateTestData() -> [String] {
var a = [String]()
for i in 0..<N {
a.append(",,abc, 123 ,x, , more more more,\u{A0}and yet more, \(i)")
}
return a
}
The running time of generateTestData() isn't what we measure but apparently the performance improvement you found only works if the same string is used every time. Otherwise performance drops.