Improve internal procedures

This commit is contained in:
gingerBill
2021-10-25 01:28:06 +01:00
parent d62c701a43
commit aaaddd03a6
2 changed files with 11 additions and 21 deletions
+2 -8
View File
@@ -128,14 +128,8 @@ compare_ptrs :: proc "contextless" (a, b: rawptr, n: int) -> int {
return compare_byte_ptrs((^byte)(a), (^byte)(b), n)
}
ptr_offset :: proc "contextless" (ptr: $P/^$T, n: int) -> P {
new := int(uintptr(ptr)) + size_of(T)*n
return P(uintptr(new))
}
ptr_sub :: proc "contextless" (a, b: $P/^$T) -> int {
return (int(uintptr(a)) - int(uintptr(b)))/size_of(T)
}
ptr_offset :: intrinsics.ptr_offset
ptr_sub :: intrinsics.ptr_sub
slice_ptr :: proc "contextless" (ptr: ^$T, len: int) -> []T {
return ([^]T)(ptr)[:len]