github.com/aloncn/graphics-go@v0.0.1/src/runtime/noasm.go (about) 1 // Copyright 2013 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // Routines that are implemented in assembly in asm_{amd64,386,arm,arm64,ppc64x}.s 6 7 // +build mips64 mips64le 8 9 package runtime 10 11 import _ "unsafe" // for go:linkname 12 13 func cmpstring(s1, s2 string) int { 14 l := len(s1) 15 if len(s2) < l { 16 l = len(s2) 17 } 18 for i := 0; i < l; i++ { 19 c1, c2 := s1[i], s2[i] 20 if c1 < c2 { 21 return -1 22 } 23 if c1 > c2 { 24 return +1 25 } 26 } 27 if len(s1) < len(s2) { 28 return -1 29 } 30 if len(s1) > len(s2) { 31 return +1 32 } 33 return 0 34 } 35 36 //go:linkname bytes_Compare bytes.Compare 37 func bytes_Compare(s1, s2 []byte) int { 38 l := len(s1) 39 if len(s2) < l { 40 l = len(s2) 41 } 42 if l == 0 || &s1[0] == &s2[0] { 43 goto samebytes 44 } 45 for i := 0; i < l; i++ { 46 c1, c2 := s1[i], s2[i] 47 if c1 < c2 { 48 return -1 49 } 50 if c1 > c2 { 51 return +1 52 } 53 } 54 samebytes: 55 if len(s1) < len(s2) { 56 return -1 57 } 58 if len(s1) > len(s2) { 59 return +1 60 } 61 return 0 62 }