mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-08 16:48:18 +00:00
[core]: Remove do keyword from the core library
This commit is contained in:
@@ -80,13 +80,15 @@ sort :: proc(sorter: ^$S/Sorter($K)) -> (sorted, cycled: [dynamic]K) {
|
||||
}
|
||||
}
|
||||
|
||||
for root in sorted do for k, _ in relations[root].dependents {
|
||||
for root in sorted {
|
||||
for k, _ in relations[root].dependents {
|
||||
relation := &relations[k]
|
||||
relation.dependencies -= 1
|
||||
if relation.dependencies == 0 {
|
||||
append(&sorted, k)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for k, v in relations {
|
||||
if v.dependencies != 0 {
|
||||
|
||||
@@ -33,7 +33,9 @@ init_from_f64 :: proc(x: ^$T/Fixed($Backing, $Fraction_Width), val: f64) {
|
||||
x.i = Backing(f * (1<<Fraction_Width))
|
||||
x.i &= 1<<Fraction_Width - 1
|
||||
x.i |= Backing(i) << Fraction_Width
|
||||
if val < 0 do x.i *= -1
|
||||
if val < 0 {
|
||||
x.i *= -1
|
||||
}
|
||||
}
|
||||
|
||||
init_from_parts :: proc(x: ^$T/Fixed($Backing, $Fraction_Width), integer, fraction: Backing) {
|
||||
|
||||
@@ -749,7 +749,9 @@ dynamic_pool_alloc_bytes :: proc(p: ^Dynamic_Pool, bytes: int) -> ([]byte, Alloc
|
||||
n := bytes
|
||||
extra := p.alignment - (n % p.alignment)
|
||||
n += extra
|
||||
if n > p.block_size do return nil, .Invalid_Argument
|
||||
if n > p.block_size {
|
||||
return nil, .Invalid_Argument
|
||||
}
|
||||
if n >= p.out_band_size {
|
||||
assert(p.block_allocator.procedure != nil)
|
||||
memory, err := p.block_allocator.procedure(p.block_allocator.data, Allocator_Mode.Alloc,
|
||||
|
||||
+3
-1
@@ -462,7 +462,9 @@ split_port :: proc(endpoint_str: string) -> (addr_or_host: string, port: int, ok
|
||||
// Joins an address or hostname with a port.
|
||||
join_port :: proc(address_or_host: string, port: int, allocator := context.allocator) -> string {
|
||||
addr_or_host, _, ok := split_port(address_or_host)
|
||||
if !ok do return addr_or_host
|
||||
if !ok {
|
||||
return addr_or_host
|
||||
}
|
||||
|
||||
b := strings.builder_make(allocator)
|
||||
|
||||
|
||||
@@ -333,7 +333,9 @@ _set_option :: proc(sock: Any_Socket, option: Socket_Option, value: any, loc :=
|
||||
.Send_Timeout,
|
||||
.Receive_Timeout:
|
||||
t, ok := value.(time.Duration)
|
||||
if !ok do panic("set_option() value must be a time.Duration here", loc)
|
||||
if !ok {
|
||||
panic("set_option() value must be a time.Duration here", loc)
|
||||
}
|
||||
|
||||
micros := cast(i64) (time.duration_microseconds(t))
|
||||
timeval_value.microseconds = cast(int) (micros % 1e6)
|
||||
|
||||
+9
-3
@@ -123,7 +123,9 @@ percent_encode :: proc(s: string, allocator := context.allocator) -> string {
|
||||
percent_decode :: proc(encoded_string: string, allocator := context.allocator) -> (decoded_string: string, ok: bool) {
|
||||
b := strings.builder_make(allocator)
|
||||
strings.builder_grow(&b, len(encoded_string))
|
||||
defer if !ok do strings.builder_destroy(&b)
|
||||
defer if !ok {
|
||||
strings.builder_destroy(&b)
|
||||
}
|
||||
|
||||
s := encoded_string
|
||||
|
||||
@@ -137,7 +139,9 @@ percent_decode :: proc(encoded_string: string, allocator := context.allocator) -
|
||||
strings.write_string(&b, s[:i])
|
||||
s = s[i:]
|
||||
|
||||
if len(s) == 0 do return // percent without anything after it
|
||||
if len(s) == 0 {
|
||||
return // percent without anything after it
|
||||
}
|
||||
s = s[1:]
|
||||
|
||||
if s[0] == '%' {
|
||||
@@ -177,7 +181,9 @@ base64url_encode :: proc(data: []byte, allocator := context.allocator) -> string
|
||||
}
|
||||
i := len(out)-1;
|
||||
for ; i >= 0; i -= 1 {
|
||||
if out[i] != '=' do break;
|
||||
if out[i] != '=' {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return string(out[:i+1]);
|
||||
}
|
||||
|
||||
@@ -107,7 +107,8 @@ clone_node :: proc(node: ^Node) -> ^Node {
|
||||
reflect.set_union_value(ds, res_ptr_any)
|
||||
}
|
||||
|
||||
if res.derived != nil do switch r in res.derived {
|
||||
if res.derived != nil {
|
||||
switch r in res.derived {
|
||||
case ^Package, ^File:
|
||||
case ^Bad_Expr:
|
||||
case ^Ident:
|
||||
@@ -328,6 +329,7 @@ clone_node :: proc(node: ^Node) -> ^Node {
|
||||
case:
|
||||
fmt.panicf("Unhandled node kind: %v", r)
|
||||
}
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
@@ -26,7 +26,9 @@ package heap
|
||||
make :: proc(data: []$T, less: proc(a, b: T) -> bool) {
|
||||
// amoritize length lookup
|
||||
length := len(data)
|
||||
if length <= 1 do return
|
||||
if length <= 1 {
|
||||
return
|
||||
}
|
||||
|
||||
// start from data parent, no need to consider children
|
||||
for start := (length - 2) / 2; start >= 0; start -= 1 {
|
||||
@@ -53,7 +55,9 @@ push :: proc(data: []$T, less: proc(a, b: T) -> bool) {
|
||||
*/
|
||||
pop :: proc(data: []$T, less: proc(a, b: T) -> bool) {
|
||||
length := len(data)
|
||||
if length <= 1 do return
|
||||
if length <= 1 {
|
||||
return
|
||||
}
|
||||
|
||||
last := length
|
||||
|
||||
@@ -206,7 +210,9 @@ sift_up :: proc(data: []$T, less: proc(a, b: T) -> bool) {
|
||||
// amoritize length lookup
|
||||
length := len(data)
|
||||
|
||||
if length <= 1 do return
|
||||
if length <= 1 {
|
||||
return
|
||||
}
|
||||
|
||||
last := length
|
||||
length = (length - 2) / 2
|
||||
|
||||
+18
-6
@@ -147,7 +147,9 @@ create_and_start :: proc(fn: proc(), init_context: Maybe(runtime.Context) = nil,
|
||||
}
|
||||
t := create(thread_proc, priority)
|
||||
t.data = rawptr(fn)
|
||||
if self_cleanup do t.flags += {.Self_Cleanup}
|
||||
if self_cleanup {
|
||||
t.flags += {.Self_Cleanup}
|
||||
}
|
||||
t.init_context = init_context
|
||||
start(t)
|
||||
return t
|
||||
@@ -167,7 +169,9 @@ create_and_start_with_data :: proc(data: rawptr, fn: proc(data: rawptr), init_co
|
||||
t.data = rawptr(fn)
|
||||
t.user_index = 1
|
||||
t.user_args = data
|
||||
if self_cleanup do t.flags += {.Self_Cleanup}
|
||||
if self_cleanup {
|
||||
t.flags += {.Self_Cleanup}
|
||||
}
|
||||
t.init_context = init_context
|
||||
start(t)
|
||||
return t
|
||||
@@ -186,7 +190,9 @@ create_and_start_with_poly_data :: proc(data: $T, fn: proc(data: T), init_contex
|
||||
t.user_index = 1
|
||||
data := data
|
||||
mem.copy(&t.user_args[0], &data, size_of(data))
|
||||
if self_cleanup do t.flags += {.Self_Cleanup}
|
||||
if self_cleanup {
|
||||
t.flags += {.Self_Cleanup}
|
||||
}
|
||||
t.init_context = init_context
|
||||
start(t)
|
||||
return t
|
||||
@@ -208,7 +214,9 @@ create_and_start_with_poly_data2 :: proc(arg1: $T1, arg2: $T2, fn: proc(T1, T2),
|
||||
arg1, arg2 := arg1, arg2
|
||||
mem.copy(&t.user_args[0], &arg1, size_of(arg1))
|
||||
mem.copy(&t.user_args[1], &arg2, size_of(arg2))
|
||||
if self_cleanup do t.flags += {.Self_Cleanup}
|
||||
if self_cleanup {
|
||||
t.flags += {.Self_Cleanup}
|
||||
}
|
||||
t.init_context = init_context
|
||||
start(t)
|
||||
return t
|
||||
@@ -233,7 +241,9 @@ create_and_start_with_poly_data3 :: proc(arg1: $T1, arg2: $T2, arg3: $T3, fn: pr
|
||||
mem.copy(&t.user_args[0], &arg1, size_of(arg1))
|
||||
mem.copy(&t.user_args[1], &arg2, size_of(arg2))
|
||||
mem.copy(&t.user_args[2], &arg3, size_of(arg3))
|
||||
if self_cleanup do t.flags += {.Self_Cleanup}
|
||||
if self_cleanup {
|
||||
t.flags += {.Self_Cleanup}
|
||||
}
|
||||
t.init_context = init_context
|
||||
start(t)
|
||||
return t
|
||||
@@ -259,7 +269,9 @@ create_and_start_with_poly_data4 :: proc(arg1: $T1, arg2: $T2, arg3: $T3, arg4:
|
||||
mem.copy(&t.user_args[1], &arg2, size_of(arg2))
|
||||
mem.copy(&t.user_args[2], &arg3, size_of(arg3))
|
||||
mem.copy(&t.user_args[3], &arg4, size_of(arg4))
|
||||
if self_cleanup do t.flags += {.Self_Cleanup}
|
||||
if self_cleanup {
|
||||
t.flags += {.Self_Cleanup}
|
||||
}
|
||||
t.init_context = init_context
|
||||
start(t)
|
||||
return t
|
||||
|
||||
Reference in New Issue
Block a user