1
0
mirror of https://github.com/golang/go synced 2024-10-01 07:28:35 -06:00

runtime: compare only until min(len(s1), len(s2))

LGTM=bradfitz
R=rsc, bradfitz
CC=golang-codereviews
https://golang.org/cl/139770043
This commit is contained in:
David Crawshaw 2014-08-28 12:07:52 -04:00
parent f852034eb0
commit 5ea131f442

View File

@ -9,7 +9,7 @@ package runtime
func cmpstring(s1, s2 string) int {
l := len(s1)
if l < len(s2) {
if len(s2) < l {
l = len(s2)
}
for i := 0; i < l; i++ {
@ -32,7 +32,7 @@ func cmpstring(s1, s2 string) int {
func cmpbytes(s1, s2 []byte) int {
l := len(s1)
if l < len(s2) {
if len(s2) < l {
l = len(s2)
}
for i := 0; i < l; i++ {