I compiled it down and did a quick profile. Looks like a lot of the time is spent on line 96, converting a Character to its ascii value.
https://dl.dropboxusercontent.com/u/13740348/Screen%20Shot%2...
https://dl.dropboxusercontent.com/u/13740348/Screen%20Shot%2...
extension Character {
var asciiValue: UInt32? {
return String(self)
.unicodeScalars
.filter{$0.isASCII}
.first?
.value
}
}
Certainly if it is optimal, but probably also if it isn't, I would change the program to not do that conversion in inner loops.https://gist.github.com/rookie/3d9a848c6fefacc4254da921da79b...