We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b51cda9 commit b804811Copy full SHA for b804811
src/internal/bytealg/bytealg.go
@@ -42,6 +42,31 @@ func Compare(a, b []byte) int {
42
}
43
44
45
+// This function was copied from the Go 1.23 source tree (with runtime_cmpstring
46
+// manually inlined).
47
+func CompareString(a, b string) int {
48
+ l := len(a)
49
+ if len(b) < l {
50
+ l = len(b)
51
+ }
52
+ for i := 0; i < l; i++ {
53
+ c1, c2 := a[i], b[i]
54
+ if c1 < c2 {
55
+ return -1
56
57
+ if c1 > c2 {
58
+ return +1
59
60
61
+ if len(a) < len(b) {
62
63
64
+ if len(a) > len(b) {
65
66
67
+ return 0
68
+}
69
+
70
// Count the number of instances of a byte in a slice.
71
func Count(b []byte, c byte) int {
72
// Use a simple implementation, as there is no intrinsic that does this like we want.
0 commit comments