-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Description
A comment by @rsc in strings.Compare
says:
This function does NOT call the runtime cmpstring function,
because we do not want to provide any performance justification for
using strings.Compare. Basically no one should use strings.Compare.
As the comment above says, it is here only for symmetry with package bytes.
If performance is important, the compiler should be changed to recognize
the pattern so that all code doing three-way comparisons, not just code
using strings.Compare, can benefit.
I'm not sure this comment has aged well with the recent change to slices.SortFunc
,
where it now takes in an func(T, T) int
instead of func(T, T) bool
.
This means that the utility of strings.Compare
suddenly shot up.
We should either intrinsify strings.Compare
as runtime.cmpstring
OR (even better) recognize this pattern.
That way, cmp.Compare
on string
types will benefit as well.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status