Some more thoughts:
- Regex operations are still really slow in Swift, but help is coming
- Using literal regex expressions like
/\d+/
should be faster than parsing them during runtime. - From what I could find, Rust is only aware of grapheme clusters (= characters) when writing
"my text".graphemes(true)
, whereas Swift by default respects grapheme clusters, which is more expensive (e.g. when looking for a character it has to make sure no combining characters follow). components(separatedBy:)
gives you an array of Strings,split(separator:)
gives you Substrings, generally it should be cheaper to work with Substrings as long as possible. So you would actually like to have a lazysplit
…