mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 15:18:49 +00:00
Remove unneeded semicolons from the core library
This commit is contained in:
+28
-28
@@ -3,69 +3,69 @@ package slice
|
||||
import "core:mem"
|
||||
|
||||
ptr_add :: proc(p: $P/^$T, x: int) -> ^T {
|
||||
return (^T)(uintptr(p) + size_of(T)*x);
|
||||
return (^T)(uintptr(p) + size_of(T)*x)
|
||||
}
|
||||
ptr_sub :: proc(p: $P/^$T, x: int) -> ^T {
|
||||
return #force_inline ptr_add(p, -x);
|
||||
return #force_inline ptr_add(p, -x)
|
||||
}
|
||||
|
||||
ptr_swap_non_overlapping :: proc(x, y: rawptr, len: int) {
|
||||
if len <= 0 {
|
||||
return;
|
||||
return
|
||||
}
|
||||
if x == y { // Ignore pointers that are the same
|
||||
return;
|
||||
return
|
||||
}
|
||||
|
||||
Block :: distinct [4]u64;
|
||||
BLOCK_SIZE :: size_of(Block);
|
||||
Block :: distinct [4]u64
|
||||
BLOCK_SIZE :: size_of(Block)
|
||||
|
||||
i := 0;
|
||||
t := &Block{};
|
||||
i := 0
|
||||
t := &Block{}
|
||||
for ; i + BLOCK_SIZE <= len; i += BLOCK_SIZE {
|
||||
a := rawptr(uintptr(x) + uintptr(i));
|
||||
b := rawptr(uintptr(y) + uintptr(i));
|
||||
a := rawptr(uintptr(x) + uintptr(i))
|
||||
b := rawptr(uintptr(y) + uintptr(i))
|
||||
|
||||
mem.copy(t, a, BLOCK_SIZE);
|
||||
mem.copy(a, b, BLOCK_SIZE);
|
||||
mem.copy(b, t, BLOCK_SIZE);
|
||||
mem.copy(t, a, BLOCK_SIZE)
|
||||
mem.copy(a, b, BLOCK_SIZE)
|
||||
mem.copy(b, t, BLOCK_SIZE)
|
||||
}
|
||||
|
||||
if i < len {
|
||||
rem := len - i;
|
||||
rem := len - i
|
||||
|
||||
a := rawptr(uintptr(x) + uintptr(i));
|
||||
b := rawptr(uintptr(y) + uintptr(i));
|
||||
a := rawptr(uintptr(x) + uintptr(i))
|
||||
b := rawptr(uintptr(y) + uintptr(i))
|
||||
|
||||
mem.copy(t, a, rem);
|
||||
mem.copy(a, b, rem);
|
||||
mem.copy(b, t, rem);
|
||||
mem.copy(t, a, rem)
|
||||
mem.copy(a, b, rem)
|
||||
mem.copy(b, t, rem)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ptr_rotate :: proc(left: int, mid: ^$T, right: int) {
|
||||
when size_of(T) != 0 {
|
||||
left, mid, right := left, mid, right;
|
||||
left, mid, right := left, mid, right
|
||||
|
||||
// TODO(bill): Optimization with a buffer for smaller ranges
|
||||
if left >= right {
|
||||
for {
|
||||
ptr_swap_non_overlapping(ptr_sub(mid, right), mid, right);
|
||||
mid = ptr_sub(mid, right);
|
||||
ptr_swap_non_overlapping(ptr_sub(mid, right), mid, right)
|
||||
mid = ptr_sub(mid, right)
|
||||
|
||||
left -= right;
|
||||
left -= right
|
||||
if left < right {
|
||||
break;
|
||||
break
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ptr_swap_non_overlapping(ptr_sub(mid, left), mid, left);
|
||||
mid = ptr_add(mid, left);
|
||||
ptr_swap_non_overlapping(ptr_sub(mid, left), mid, left)
|
||||
mid = ptr_add(mid, left)
|
||||
|
||||
right -= left;
|
||||
right -= left
|
||||
if right < left {
|
||||
break;
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user