Jens has reported:
For some particular arrays of strings, creating a Set<String>(arrayOfStrings) takes about 100 to 200 times longer than for other very similar arrays of strings (equally many unique simple [a-zA-Z ]+ strings).
I've put together a tiny program to demonstrate the problem here:
Just thought I should mention that I tried another thing:
Using my original example:
Keeping the code as it is but adding a space to the end of every line in the actual text file (strings.txt).
Another thing I noticed is that making a Set<NSString> (rather than a Set<String>) is fast ...
That is (for those same particular strings) this is fast (0.7 s):
let setOfNSStrings = Set<NSString>(strings.map
while this is slow (9.5 s):
let setOfNSStrings = Set<String>(strings)