[Swift]字符串遍历效率记录
2017-02-07 本文已影响81人
PlutoMa
for theChar in s.characters {
//something
}
效率:
1.pngfor i in 0..<s.characters.count {
let theChar = s[s.index(s.startIndex, offsetBy: i)]
//something
}
效率:
2.png for theChar in s.characters {
//something
}
效率:
1.pngfor i in 0..<s.characters.count {
let theChar = s[s.index(s.startIndex, offsetBy: i)]
//something
}
效率:
2.png