With "π¨βπ©βπ§βπ¦\n1\n2\n"
as input:
$ swiftc LineEndsFind.swift && ./LineEndsFind
Unicode unsafe time for 1M strings: 1.12317534297472
Unicode safe time for 1M strings: 3.4386172790546
Unicode unsafe result: [11, 13, 15]
Unicode safe result: [1, 3, 5]
$ clang++ LineEndsFind.mm -ObjC++ -std=c++14 -fobjc-arc -framework QuartzCore -o main && ./main
Unicode unsafe time for 1M strings: 0.876858
Unicode unsafe result: 11 13 15
hey, guess it might be better to make this comparison when compiled with optimisations.
On my MBP 13':
while
and C++:
Quite a difference there for the unicode safe solution