|
@@ -54,48 +54,7 @@ compare :: proc "contextless" (a, b: []byte) -> int {
|
|
|
}
|
|
|
|
|
|
compare_byte_ptrs :: proc "contextless" (a, b: ^byte, n: int) -> int #no_bounds_check {
|
|
|
- switch {
|
|
|
- case a == b:
|
|
|
- return 0
|
|
|
- case a == nil:
|
|
|
- return -1
|
|
|
- case b == nil:
|
|
|
- return -1
|
|
|
- case n == 0:
|
|
|
- return 0
|
|
|
- }
|
|
|
-
|
|
|
- x := slice_ptr(a, n)
|
|
|
- y := slice_ptr(b, n)
|
|
|
-
|
|
|
- SU :: size_of(uintptr)
|
|
|
- fast := n/SU + 1
|
|
|
- offset := (fast-1)*SU
|
|
|
- curr_block := 0
|
|
|
- if n < SU {
|
|
|
- fast = 0
|
|
|
- }
|
|
|
-
|
|
|
- la := slice_ptr((^uintptr)(a), fast)
|
|
|
- lb := slice_ptr((^uintptr)(b), fast)
|
|
|
-
|
|
|
- for /**/; curr_block < fast; curr_block += 1 {
|
|
|
- if la[curr_block] ~ lb[curr_block] != 0 {
|
|
|
- for pos := curr_block*SU; pos < n; pos += 1 {
|
|
|
- if x[pos] ~ y[pos] != 0 {
|
|
|
- return (int(x[pos]) - int(y[pos])) < 0 ? -1 : +1
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- for /**/; offset < n; offset += 1 {
|
|
|
- if x[offset] ~ y[offset] != 0 {
|
|
|
- return (int(x[offset]) - int(y[offset])) < 0 ? -1 : +1
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return 0
|
|
|
+ return runtime.memory_compare(a, b, n)
|
|
|
}
|
|
|
|
|
|
check_zero :: proc(data: []byte) -> bool {
|