2014-08-28 08:46:59 -06:00
|
|
|
// Copyright 2013 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2015-03-24 03:37:10 -06:00
|
|
|
// Routines that are implemented in assembly in asm_{amd64,386,arm}.s
|
2014-08-28 08:46:59 -06:00
|
|
|
|
2015-03-24 03:37:10 -06:00
|
|
|
// +build arm64 ppc64 ppc64le
|
2014-10-22 12:02:04 -06:00
|
|
|
|
2014-08-28 08:46:59 -06:00
|
|
|
package runtime
|
|
|
|
|
2014-12-22 22:03:40 -07:00
|
|
|
import _ "unsafe" // for go:linkname
|
2014-12-22 21:44:41 -07:00
|
|
|
|
2014-08-28 08:46:59 -06:00
|
|
|
func cmpstring(s1, s2 string) int {
|
|
|
|
l := len(s1)
|
2014-08-28 10:07:52 -06:00
|
|
|
if len(s2) < l {
|
2014-08-28 08:46:59 -06:00
|
|
|
l = len(s2)
|
|
|
|
}
|
|
|
|
for i := 0; i < l; i++ {
|
|
|
|
c1, c2 := s1[i], s2[i]
|
|
|
|
if c1 < c2 {
|
|
|
|
return -1
|
|
|
|
}
|
|
|
|
if c1 > c2 {
|
|
|
|
return +1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if len(s1) < len(s2) {
|
|
|
|
return -1
|
|
|
|
}
|
|
|
|
if len(s1) > len(s2) {
|
|
|
|
return +1
|
|
|
|
}
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2014-12-22 11:27:53 -07:00
|
|
|
//go:linkname bytes_Compare bytes.Compare
|
|
|
|
func bytes_Compare(s1, s2 []byte) int {
|
2014-08-28 08:46:59 -06:00
|
|
|
l := len(s1)
|
2014-08-28 10:07:52 -06:00
|
|
|
if len(s2) < l {
|
2014-08-28 08:46:59 -06:00
|
|
|
l = len(s2)
|
|
|
|
}
|
|
|
|
for i := 0; i < l; i++ {
|
|
|
|
c1, c2 := s1[i], s2[i]
|
|
|
|
if c1 < c2 {
|
|
|
|
return -1
|
|
|
|
}
|
|
|
|
if c1 > c2 {
|
|
|
|
return +1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if len(s1) < len(s2) {
|
|
|
|
return -1
|
|
|
|
}
|
|
|
|
if len(s1) > len(s2) {
|
|
|
|
return +1
|
|
|
|
}
|
|
|
|
return 0
|
|
|
|
}
|