mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-29 02:40:05 +00:00
Minimize unneeded casts
This commit is contained in:
@@ -127,7 +127,7 @@ default_temp_allocator_proc :: proc(allocator_data: rawptr, mode: Allocator_Mode
|
||||
old_ptr := uintptr(old_memory);
|
||||
|
||||
if s.prev_allocation == old_memory {
|
||||
s.curr_offset = int(uintptr(s.prev_allocation) - uintptr(start));
|
||||
s.curr_offset = int(uintptr(s.prev_allocation) - start);
|
||||
s.prev_allocation = nil;
|
||||
return nil;
|
||||
}
|
||||
|
||||
@@ -159,14 +159,14 @@ __get_map_header :: proc "contextless" (m: ^$T/map[$K]$V) -> Map_Header {
|
||||
|
||||
header.equal = intrinsics.type_equal_proc(K);
|
||||
|
||||
header.entry_size = int(size_of(Entry));
|
||||
header.entry_align = int(align_of(Entry));
|
||||
header.entry_size = size_of(Entry);
|
||||
header.entry_align = align_of(Entry);
|
||||
|
||||
header.key_offset = uintptr(offset_of(Entry, key));
|
||||
header.key_size = int(size_of(K));
|
||||
header.key_offset = offset_of(Entry, key);
|
||||
header.key_size = size_of(K);
|
||||
|
||||
header.value_offset = uintptr(offset_of(Entry, value));
|
||||
header.value_size = int(size_of(V));
|
||||
header.value_offset = offset_of(Entry, value);
|
||||
header.value_size = size_of(V);
|
||||
|
||||
return header;
|
||||
}
|
||||
|
||||
@@ -203,17 +203,17 @@ make_map_expr_error_loc :: #force_inline proc "contextless" (loc := #caller_loca
|
||||
|
||||
|
||||
bounds_check_error_loc :: #force_inline proc "contextless" (using loc := #caller_location, index, count: int) {
|
||||
bounds_check_error(file_path, int(line), int(column), index, count);
|
||||
bounds_check_error(file_path, line, column, index, count);
|
||||
}
|
||||
|
||||
slice_expr_error_hi_loc :: #force_inline proc "contextless" (using loc := #caller_location, hi: int, len: int) {
|
||||
slice_expr_error_hi(file_path, int(line), int(column), hi, len);
|
||||
slice_expr_error_hi(file_path, line, column, hi, len);
|
||||
}
|
||||
|
||||
slice_expr_error_lo_hi_loc :: #force_inline proc "contextless" (using loc := #caller_location, lo, hi: int, len: int) {
|
||||
slice_expr_error_lo_hi(file_path, int(line), int(column), lo, hi, len);
|
||||
slice_expr_error_lo_hi(file_path, line, column, lo, hi, len);
|
||||
}
|
||||
|
||||
dynamic_array_expr_error_loc :: #force_inline proc "contextless" (using loc := #caller_location, low, high, max: int) {
|
||||
dynamic_array_expr_error(file_path, int(line), int(column), low, high, max);
|
||||
dynamic_array_expr_error(file_path, line, column, low, high, max);
|
||||
}
|
||||
|
||||
@@ -195,7 +195,7 @@ memory_compare :: proc "contextless" (a, b: rawptr, n: int) -> int #no_bounds_ch
|
||||
n := uintptr(n);
|
||||
|
||||
SU :: size_of(uintptr);
|
||||
fast := uintptr(n/SU + 1);
|
||||
fast := n/SU + 1;
|
||||
offset := (fast-1)*SU;
|
||||
curr_block := uintptr(0);
|
||||
if n < SU {
|
||||
@@ -232,7 +232,7 @@ memory_compare_zero :: proc "contextless" (a: rawptr, n: int) -> int #no_bounds_
|
||||
n := uintptr(n);
|
||||
|
||||
SU :: size_of(uintptr);
|
||||
fast := uintptr(n/SU + 1);
|
||||
fast := n/SU + 1;
|
||||
offset := (fast-1)*SU;
|
||||
curr_block := uintptr(0);
|
||||
if n < SU {
|
||||
|
||||
@@ -63,8 +63,8 @@ fixdfti :: proc(a: u64) -> i128 {
|
||||
aRep := a;
|
||||
aAbs := aRep & absMask;
|
||||
sign := i128(-1 if aRep & signBit != 0 else 1);
|
||||
exponent := u64((aAbs >> significandBits) - exponentBias);
|
||||
significand := u64((aAbs & significandMask) | implicitBit);
|
||||
exponent := (aAbs >> significandBits) - exponentBias;
|
||||
significand := (aAbs & significandMask) | implicitBit;
|
||||
|
||||
// If exponent is negative, the result is zero.
|
||||
if exponent < 0 {
|
||||
@@ -103,7 +103,7 @@ floattidf :: proc(a: i128) -> f64 {
|
||||
s := a >> (N-1);
|
||||
a = (a ~ s) - s;
|
||||
sd: = N - _clz_i128(a); // number of significant digits
|
||||
e := u32(sd - 1); // exponent
|
||||
e := u32(sd - 1); // exponent
|
||||
if sd > DBL_MANT_DIG {
|
||||
switch sd {
|
||||
case DBL_MANT_DIG + 1:
|
||||
@@ -115,8 +115,8 @@ floattidf :: proc(a: i128) -> f64 {
|
||||
i128(u128(a) & (~u128(0) >> u128(N + DBL_MANT_DIG+2 - sd)) != 0);
|
||||
};
|
||||
|
||||
a |= i128((a & 4) != 0);
|
||||
a += 1;
|
||||
a |= i128((a & 4) != 0);
|
||||
a += 1;
|
||||
a >>= 2;
|
||||
|
||||
if a & (1 << DBL_MANT_DIG) != 0 {
|
||||
|
||||
Reference in New Issue
Block a user