blob: fe3591e8a37ea6a3895466ed7bf33789d20fed37 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
// 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.
// Routines that are implemented in assembly in asm_{amd64,386}.s
// but are implemented in C for arm.
package runtime
#include "runtime.h"
#include "../../cmd/ld/textflag.h"
#pragma textflag NOSPLIT
func cmpstring(s1 String, s2 String) (v int) {
uintgo i, l;
byte c1, c2;
l = s1.len;
if(s2.len < l)
l = s2.len;
for(i=0; i<l; i++) {
c1 = s1.str[i];
c2 = s2.str[i];
if(c1 < c2) {
v = -1;
goto done;
}
if(c1 > c2) {
v = +1;
goto done;
}
}
if(s1.len < s2.len) {
v = -1;
goto done;
}
if(s1.len > s2.len) {
v = +1;
goto done;
}
v = 0;
done:;
}
#pragma textflag NOSPLIT
func bytes·Compare(s1 Slice, s2 Slice) (v int) {
uintgo i, l;
byte c1, c2;
l = s1.len;
if(s2.len < l)
l = s2.len;
for(i=0; i<l; i++) {
c1 = s1.array[i];
c2 = s2.array[i];
if(c1 < c2) {
v = -1;
goto done;
}
if(c1 > c2) {
v = +1;
goto done;
}
}
if(s1.len < s2.len) {
v = -1;
goto done;
}
if(s1.len > s2.len) {
v = +1;
goto done;
}
v = 0;
done:;
}
|