Re:Strings, bytes, runes and characters in Go
by masklinn on Thursday October 24, 2013 @05:18AM
(#6604169)
> To find an index of a substring you need to scan the string, right. But once you have the byte index you can quickly jump to its position in the string
Stop doing that and just get the bit of string you want in the first place?
To find an index of a substring you need to scan the string, right. But once you have the byte index you can quickly jump to its position in the string, e.g. when you do a slice operation based on that index: s[i:]. If strings.Index() returned a code point index and not a byte index you would have to scan the string again.