Even more style fixes

This commit is contained in:
gingerBill
2024-06-29 19:11:36 +01:00
parent 3f9a58808c
commit 5413a8b744
17 changed files with 41 additions and 46 deletions
+1 -1
View File
@@ -679,7 +679,7 @@ allocate_memory :: proc(a: ^WASM_Allocator, alignment: uint, size: uint, loc :=
// but we just had a stale bit set to mark a populated bucket. // but we just had a stale bit set to mark a populated bucket.
// Reset the bit to update latest status so that we do not // Reset the bit to update latest status so that we do not
// redundantly look at this bucket again. // redundantly look at this bucket again.
a.free_region_buckets_used &= ~(BUCKET_BITMASK_T(1) << bucket_index) a.free_region_buckets_used &~= BUCKET_BITMASK_T(1) << bucket_index
bucket_mask ~= 1 bucket_mask ~= 1
} }
+2 -2
View File
@@ -211,7 +211,7 @@ set :: proc(ba: ^Bit_Array, #any_int index: uint, set_to: bool = true, allocator
ba.max_index = max(idx, ba.max_index) ba.max_index = max(idx, ba.max_index)
if set_to{ ba.bits[leg_index] |= 1 << uint(bit_index) } if set_to{ ba.bits[leg_index] |= 1 << uint(bit_index) }
else { ba.bits[leg_index] &= ~(1 << uint(bit_index)) } else { ba.bits[leg_index] &~= 1 << uint(bit_index) }
return true return true
} }
@@ -253,7 +253,7 @@ Inputs:
- index: Which bit in the array - index: Which bit in the array
*/ */
unsafe_unset :: proc(b: ^Bit_Array, bit: int) #no_bounds_check { unsafe_unset :: proc(b: ^Bit_Array, bit: int) #no_bounds_check {
b.bits[bit >> INDEX_SHIFT] &= ~(1 << uint(bit & INDEX_MASK)) b.bits[bit >> INDEX_SHIFT] &~= 1 << uint(bit & INDEX_MASK)
} }
/* /*
A helper function to create a Bit Array with optional bias, in case your smallest index is non-zero (including negative). A helper function to create a Bit Array with optional bias, in case your smallest index is non-zero (including negative).
+1 -1
View File
@@ -233,7 +233,7 @@ encode_into_encoder :: proc(e: Encoder, v: Value, loc := #caller_location) -> En
if .Self_Described_CBOR in e.flags { if .Self_Described_CBOR in e.flags {
_encode_u64(e, TAG_SELF_DESCRIBED_CBOR, .Tag) or_return _encode_u64(e, TAG_SELF_DESCRIBED_CBOR, .Tag) or_return
e.flags &~= { .Self_Described_CBOR } e.flags -= { .Self_Described_CBOR }
} }
switch v_spec in v { switch v_spec in v {
+1 -1
View File
@@ -85,7 +85,7 @@ marshal_into_encoder :: proc(e: Encoder, v: any, loc := #caller_location) -> (e
if .Self_Described_CBOR in e.flags { if .Self_Described_CBOR in e.flags {
err_conv(_encode_u64(e, TAG_SELF_DESCRIBED_CBOR, .Tag)) or_return err_conv(_encode_u64(e, TAG_SELF_DESCRIBED_CBOR, .Tag)) or_return
e.flags &~= { .Self_Described_CBOR } e.flags -= { .Self_Described_CBOR }
} }
if v == nil { if v == nil {
+6 -9
View File
@@ -1072,8 +1072,8 @@ _fmt_int :: proc(fi: ^Info, u: u64, base: int, is_signed: bool, bit_size: int, d
} }
flags: strconv.Int_Flags flags: strconv.Int_Flags
if fi.hash && !fi.zero && start == 0 { flags |= {.Prefix} } if fi.hash && !fi.zero && start == 0 { flags += {.Prefix} }
if fi.plus { flags |= {.Plus} } if fi.plus { flags += {.Plus} }
s := strconv.append_bits(buf[start:], u, base, is_signed, bit_size, digits, flags) s := strconv.append_bits(buf[start:], u, base, is_signed, bit_size, digits, flags)
prev_zero := fi.zero prev_zero := fi.zero
defer fi.zero = prev_zero defer fi.zero = prev_zero
@@ -1157,8 +1157,8 @@ _fmt_int_128 :: proc(fi: ^Info, u: u128, base: int, is_signed: bool, bit_size: i
} }
flags: strconv.Int_Flags flags: strconv.Int_Flags
if fi.hash && !fi.zero && start == 0 { flags |= {.Prefix} } if fi.hash && !fi.zero && start == 0 { flags += {.Prefix} }
if fi.plus { flags |= {.Plus} } if fi.plus { flags += {.Plus} }
s := strconv.append_bits_128(buf[start:], u, base, is_signed, bit_size, digits, flags) s := strconv.append_bits_128(buf[start:], u, base, is_signed, bit_size, digits, flags)
if fi.hash && fi.zero && fi.indent == 0 { if fi.hash && fi.zero && fi.indent == 0 {
@@ -1460,13 +1460,10 @@ fmt_string :: proc(fi: ^Info, s: string, verb: rune) {
if !fi.minus { if !fi.minus {
io.write_string(fi.writer, s, &fi.n) io.write_string(fi.writer, s, &fi.n)
} }
} } else {
else {
io.write_string(fi.writer, s, &fi.n) io.write_string(fi.writer, s, &fi.n)
} }
} } else {
else
{
io.write_string(fi.writer, s, &fi.n) io.write_string(fi.writer, s, &fi.n)
} }
+1 -1
View File
@@ -131,7 +131,7 @@ load_from_context :: proc(ctx: ^$C, options := Options{}, allocator := context.a
runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD()
if .info in options { if .info in options {
options |= {.return_metadata, .do_not_decompress_image} options += {.return_metadata, .do_not_decompress_image}
options -= {.info} options -= {.info}
} }
+2 -2
View File
@@ -341,7 +341,7 @@ load_from_context :: proc(ctx: ^$C, options := Options{}, allocator := context.a
options := options options := options
if .info in options { if .info in options {
options |= {.return_metadata, .do_not_decompress_image} options += {.return_metadata, .do_not_decompress_image}
options -= {.info} options -= {.info}
} }
@@ -354,7 +354,7 @@ load_from_context :: proc(ctx: ^$C, options := Options{}, allocator := context.a
} }
if .do_not_expand_channels in options { if .do_not_expand_channels in options {
options |= {.do_not_expand_grayscale, .do_not_expand_indexed} options += {.do_not_expand_grayscale, .do_not_expand_indexed}
} }
if img == nil { if img == nil {
+1 -1
View File
@@ -176,7 +176,7 @@ load_from_context :: proc(ctx: ^$C, options := Options{}, allocator := context.a
options := options options := options
if .info in options { if .info in options {
options |= {.return_metadata, .do_not_decompress_image} options += {.return_metadata, .do_not_decompress_image}
options -= {.info} options -= {.info}
} }
+1 -1
View File
@@ -100,7 +100,7 @@ load_from_context :: proc(ctx: ^$C, options := Options{}, allocator := context.a
} }
if .info in options { if .info in options {
options |= {.return_metadata, .do_not_decompress_image} options += {.return_metadata, .do_not_decompress_image}
options -= {.info} options -= {.info}
} }
+5 -7
View File
@@ -637,22 +637,20 @@ _internal_noise_4d_unskewed_base :: proc(seed: i64, coord: Vec4) -> (value: f32)
// Next point is the closest vertex on the 4-simplex whose base vertex is the aforementioned vertex. // Next point is the closest vertex on the 4-simplex whose base vertex is the aforementioned vertex.
score := 1.0 + ssi * (-1.0 / UNSKEW_4D) // Seems slightly faster than 1.0-xsi-ysi-zsi-wsi score := 1.0 + ssi * (-1.0 / UNSKEW_4D) // Seems slightly faster than 1.0-xsi-ysi-zsi-wsi
if si.x >= si.x && si.x >= si.z && si.x >= si.w && si.x >= score { switch {
case si.x >= si.x && si.x >= si.z && si.x >= si.w && si.x >= score:
svp.x += PRIME_X svp.x += PRIME_X
si.x -= 1 si.x -= 1
ssi -= UNSKEW_4D ssi -= UNSKEW_4D
} case si.y > si.x && si.y >= si.z && si.y >= si.w && si.y >= score:
else if si.y > si.x && si.y >= si.z && si.y >= si.w && si.y >= score {
svp.y += PRIME_Y svp.y += PRIME_Y
si.y -= 1 si.y -= 1
ssi -= UNSKEW_4D ssi -= UNSKEW_4D
} case si.z > si.x && si.z > si.y && si.z >= si.w && si.z >= score:
else if si.z > si.x && si.z > si.y && si.z >= si.w && si.z >= score {
svp.z += PRIME_Z svp.z += PRIME_Z
si.z -= 1 si.z -= 1
ssi -= UNSKEW_4D ssi -= UNSKEW_4D
} case si.w > si.x && si.w > si.y && si.w > si.z && si.w >= score:
else if si.w > si.x && si.w > si.y && si.w > si.z && si.w >= score {
svp.w += PRIME_W svp.w += PRIME_W
si.w -= 1 si.w -= 1
ssi -= UNSKEW_4D ssi -= UNSKEW_4D
+3 -3
View File
@@ -36,9 +36,9 @@ _release :: proc "contextless" (data: rawptr, size: uint) {
_protect :: proc "contextless" (data: rawptr, size: uint, flags: Protect_Flags) -> bool { _protect :: proc "contextless" (data: rawptr, size: uint, flags: Protect_Flags) -> bool {
pflags: linux.Mem_Protection pflags: linux.Mem_Protection
pflags = {} pflags = {}
if .Read in flags { pflags |= {.READ} } if .Read in flags { pflags += {.READ} }
if .Write in flags { pflags |= {.WRITE} } if .Write in flags { pflags += {.WRITE} }
if .Execute in flags { pflags |= {.EXEC} } if .Execute in flags { pflags += {.EXEC} }
errno := linux.mprotect(data, size, pflags) errno := linux.mprotect(data, size, pflags)
return errno == .NONE return errno == .NONE
} }
+2 -2
View File
@@ -94,7 +94,7 @@ _enumerate_interfaces :: proc(allocator := context.allocator) -> (interfaces: []
state := Link_State{} state := Link_State{}
if .UP in ifaddr.flags { if .UP in ifaddr.flags {
state |= {.Up} state += {.Up}
} }
/*if .DORMANT in ifaddr.flags { /*if .DORMANT in ifaddr.flags {
@@ -102,7 +102,7 @@ _enumerate_interfaces :: proc(allocator := context.allocator) -> (interfaces: []
}*/ }*/
if .LOOPBACK in ifaddr.flags { if .LOOPBACK in ifaddr.flags {
state |= {.Loopback} state += {.Loopback}
} }
iface.link.state = state iface.link.state = state
} }
+1 -1
View File
@@ -320,7 +320,7 @@ _set_blocking :: proc(socket: Any_Socket, should_block: bool) -> (err: Network_E
} }
if should_block { if should_block {
flags &= ~int(os.O_NONBLOCK) flags &~= int(os.O_NONBLOCK)
} else { } else {
flags |= int(os.O_NONBLOCK) flags |= int(os.O_NONBLOCK)
} }
+2 -2
View File
@@ -377,9 +377,9 @@ _set_blocking :: proc(sock: Any_Socket, should_block: bool) -> (err: Network_Err
return Set_Blocking_Error(errno) return Set_Blocking_Error(errno)
} }
if should_block { if should_block {
flags &= ~{.NONBLOCK} flags -= {.NONBLOCK}
} else { } else {
flags |= {.NONBLOCK} flags += {.NONBLOCK}
} }
errno = linux.fcntl(os_sock, linux.F_SETFL, flags) errno = linux.fcntl(os_sock, linux.F_SETFL, flags)
if errno != .NONE { if errno != .NONE {
+1 -1
View File
@@ -711,7 +711,7 @@ enumerated_array :: proc(ptr: ^$T) -> []intrinsics.type_elem_type(T)
@(require_results) @(require_results)
enum_slice_to_bitset :: proc(enums: []$E, $T: typeid/bit_set[E]) -> (bits: T) where intrinsics.type_is_enum(E), intrinsics.type_bit_set_elem_type(T) == E { enum_slice_to_bitset :: proc(enums: []$E, $T: typeid/bit_set[E]) -> (bits: T) where intrinsics.type_is_enum(E), intrinsics.type_bit_set_elem_type(T) == E {
for v in enums { for v in enums {
bits |= {v} bits += {v}
} }
return return
} }
+10 -10
View File
@@ -1464,16 +1464,16 @@ Futex_Flags_Bits :: enum {
Kind of operation on futex, see FUTEX_WAKE_OP Kind of operation on futex, see FUTEX_WAKE_OP
*/ */
Futex_Arg_Op :: enum { Futex_Arg_Op :: enum {
SET = 0, /* uaddr2 = oparg; */ SET = 0, /* uaddr2 = oparg */
ADD = 1, /* uaddr2 += oparg; */ ADD = 1, /* uaddr2 += oparg */
OR = 2, /* uaddr2 |= oparg; */ OR = 2, /* uaddr2 |= oparg */
ANDN = 3, /* uaddr2 &= ~oparg; */ ANDN = 3, /* uaddr2 &= ~oparg */
XOR = 4, /* uaddr2 ^= oparg; */ XOR = 4, /* uaddr2 ^= oparg */
PO2_SET = 0, /* uaddr2 = 1<<oparg; */ PO2_SET = 0, /* uaddr2 = 1<<oparg */
PO2_ADD = 1, /* uaddr2 += 1<<oparg; */ PO2_ADD = 1, /* uaddr2 += 1<<oparg */
PO2_OR = 2, /* uaddr2 |= 1<<oparg; */ PO2_OR = 2, /* uaddr2 |= 1<<oparg */
PO2_ANDN = 3, /* uaddr2 &= ~(1<<oparg); */ PO2_ANDN = 3, /* uaddr2 &~= 1<<oparg */
PO2_XOR = 4, /* uaddr2 ^= 1<<oparg; */ PO2_XOR = 4, /* uaddr2 ^= 1<<oparg */
} }
/* /*
+1 -1
View File
@@ -23,7 +23,7 @@ import "core:c"
} }
@(private="file") FD_CLR :: #force_inline proc(d: i32, s: ^fd_set) { @(private="file") FD_CLR :: #force_inline proc(d: i32, s: ^fd_set) {
s.fds_bits[d / (8 * size_of(c.long))] &= ~(c.ulong(1) << (c.ulong(d) % (8 * size_of(c.ulong)))) s.fds_bits[d / (8 * size_of(c.long))] &~= c.ulong(1) << (c.ulong(d) % (8 * size_of(c.ulong)))
} }
@(private="file") FD_ISSET :: #force_inline proc(d: i32, s: ^fd_set) -> bool { @(private="file") FD_ISSET :: #force_inline proc(d: i32, s: ^fd_set) -> bool {