3 ms·
Wouldn't the normal implementation for == check lengths? Edit: Never mind, it doesn't: https://github.com/golang/go/blob/d28bf6c9a2ea9b992796738d03eb3d15ffbfc0
by tylerhou 4y ago
Wouldn't the normal implementation for == check lengths?
Edit: Never mind, it doesn't: https://github.com/golang/go/blob/d28bf6c9a2ea9b992796738d03eb3d15ffbfc0b4/src/internal/bytealg/compare_generic.go https://github.com/golang/go/blob/d28bf6c9a2ea9b992796738d03...
But checking lengths doesn't really help you: it only tells you when strings are not equal, and you would still have to walk the string to see which one is larger/smaller.
- orlp 4y ago> But checking lengths doesn't really help you: it only tells you when strings are not equal, and you would still have to walk the string to see which one is larger/smaller. Only for a three-way comparison. If all you care about is equality different lengths gives a fast path for inequality.