strings, x/exp/slices: strings.Compare is more useful than its docs say, but also slow #58142
Labels
Documentation
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
What version of Go are you using (
go version
)?What did you do?
I benchmarked two binary searches on an array of strings:
Turns out the former can be significantly faster. Seeing how strings.Compare is implemented, I get why:
go/src/strings/compare.go
Lines 7 to 28 in d42c08a
Should the decision to not optimize strings.Compare be reconsidered? Even if not, should its comments be changed to not recommend against its use? Because it appears to me as the sane way to work with strings and x/exp/slices.
The text was updated successfully, but these errors were encountered: