aboutsummaryrefslogtreecommitdiff
path: root/core/mem
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2022-08-26 16:45:40 +0100
committergingerBill <bill@gingerbill.org>2022-08-26 16:45:40 +0100
commit027ea587fcdcc7a7ac7c26e7ccd9ee31e587649d (patch)
tree2c3e248babd74ffc927ea669234342130d047adf /core/mem
parent026900c7f019a450205d41e14fc747361e565f18 (diff)
Unify mem and runtime logic
Diffstat (limited to 'core/mem')
-rw-r--r--core/mem/mem.odin43
1 files changed, 1 insertions, 42 deletions
diff --git a/core/mem/mem.odin b/core/mem/mem.odin
index 7295a2afa..f7be69adc 100644
--- a/core/mem/mem.odin
+++ b/core/mem/mem.odin
@@ -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 {