3 ms·
ah great point. I'll time it both ways and see where I'm at.
by brothrock 10y ago
ah great point. I'll time it both ways and see where I'm at.
- pkaler 10y agoI 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%202016-11-11%20at%2010.14.33%20AM.png https://dl.dropboxusercontent.com/u/13740348/Screen%20Shot%2...
- Someone 10y agoThat's because Character is very, very different from ASCII in Swift (a character in Swift holds an extended grapheme cluster. See https://developer.apple.com/reference/swift/character https://developer.apple.com/reference/swift/character). I also doubt the way they compute its ASCII value is optimal: 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.
- brothrock 10y agoThis is awesome guys. Thanks.
- rookie 10y agoReplaced String with Int array https://gist.github.com/rookie/3d9a848c6fefacc4254da921da79b467 https://gist.github.com/rookie/3d9a848c6fefacc4254da921da79b...