<instructions>Your goal is to analyze the following comment and estimate how highly it will be upvoted by the Hacker News community.</instructions><comment><author>eis</author><text>Yep.&lt;p&gt;Here a Go playground example showing that the result is indeed wrong:&lt;p&gt;&lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;play.golang.org&amp;#x2F;p&amp;#x2F;vmctMFUevPc&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;play.golang.org&amp;#x2F;p&amp;#x2F;vmctMFUevPc&lt;/a&gt;&lt;p&gt;It should output 3 but outputs 5 because each ö is two bytes, len(&amp;quot;föö&amp;quot;) = 5.&lt;p&gt;I would suggest using &amp;quot;range&amp;quot; to iterate over the unicode characters.</text><parent_chain><item><author>molf</author><text>The Rust version uses `target.chars().count()` to initialise the cache, while the Go version counts up to `len(target)`. These are not equivalent: the Rust version counts Unicode code points, the Go version counts bytes.&lt;p&gt;I am confused by the implementations, although I have not spent any time testing them. Both versions contain a mix of code that counts bytes (`.len()` and `len(...)`) and Unicode code points (`chars()` and `[]rune(...)`). My guess is that the implementation might not work correctly for certain non-ASCII strings, but I have not verified this.&lt;p&gt;Of course, if only ASCII strings are valid as input for this implementation then both versions will be a lot faster if they exclusively operate on bytes instead.</text></item></parent_chain></comment><story><title>Making Rust as Fast as Go</title><url>https://www.christianfscott.com/making-rust-as-fast-as-go/</url></story>
<instructions>Your goal is to analyze the following comment and estimate how highly it will be upvoted by the Hacker News community.</instructions><comment><author>maxmcd</author><text>huh, yeah if I switch the rust version to target.len() the execution time drops by more than 10%&lt;p&gt;edit: and if I switch to source.bytes().enumerate() it drops by 20% more</text><parent_chain><item><author>molf</author><text>The Rust version uses `target.chars().count()` to initialise the cache, while the Go version counts up to `len(target)`. These are not equivalent: the Rust version counts Unicode code points, the Go version counts bytes.&lt;p&gt;I am confused by the implementations, although I have not spent any time testing them. Both versions contain a mix of code that counts bytes (`.len()` and `len(...)`) and Unicode code points (`chars()` and `[]rune(...)`). My guess is that the implementation might not work correctly for certain non-ASCII strings, but I have not verified this.&lt;p&gt;Of course, if only ASCII strings are valid as input for this implementation then both versions will be a lot faster if they exclusively operate on bytes instead.</text></item></parent_chain></comment><story><title>Making Rust as Fast as Go</title><url>https://www.christianfscott.com/making-rust-as-fast-as-go/</url></story>