Skip to content

strings: maybe strings.Compare should be optimized #50167

Closed
@zigo101

Description

@zigo101

What version of Go are you using (go version)?

$ go version
go version go1.17.5 linux/amd64

Does this issue reproduce with the latest release?

Yes

What did you do?

https://sourcegraph.com/search?q=context:global+switch+strings.Compare+lang:Go+&patternType=literal

What did you expect to see?

The strings.Compare should do one comparison for all cases.

What did you see instead?

The strings.Compare does two comparisons for some cases.

https://github.com/golang/go/blob/go1.17.5/src/strings/compare.go#L13

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions