blob: 2bf919efd7f4b9f17a0bdb9d675519ceac82f80c (
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
|
// +build js
package bytes
func IndexByte(s []byte, c byte) int {
for i, b := range s {
if b == c {
return i
}
}
return -1
}
func Equal(a, b []byte) bool {
if len(a) != len(b) {
return false
}
for i, c := range a {
if c != b[i] {
return false
}
}
return true
}
func Compare(a, b []byte) int {
for i, ca := range a {
if i >= len(b) {
return 1
}
cb := b[i]
if ca < cb {
return -1
}
if ca > cb {
return 1
}
}
if len(a) < len(b) {
return -1
}
return 0
}
|