Browse Source

Minimize unneeded casts

gingerBill 4 years ago
parent
commit
b727b6438b

+ 7 - 7
core/fmt/fmt.odin

@@ -1169,7 +1169,7 @@ fmt_bit_set :: proc(fi: ^Info, v: any, name: string = "") {
 		case 128:
 		case 128:
 			x := (^u128)(v.data)^;
 			x := (^u128)(v.data)^;
 			if do_byte_swap { x = byte_swap(x); }
 			if do_byte_swap { x = byte_swap(x); }
-			bits = u128(x);
+			bits = x;
 		case: panic("unknown bit_size size");
 		case: panic("unknown bit_size size");
 		}
 		}
 
 
@@ -1389,7 +1389,7 @@ fmt_value :: proc(fi: ^Info, v: any, verb: rune) {
 			t := a;
 			t := a;
 			y, mon, d := time.date(t);
 			y, mon, d := time.date(t);
 			h, min, s := time.clock(t);
 			h, min, s := time.clock(t);
-			ns := i64(t._nsec - (t._nsec/1e9 + time.UNIX_TO_ABSOLUTE)*1e9) % 1e9;
+			ns := (t._nsec - (t._nsec/1e9 + time.UNIX_TO_ABSOLUTE)*1e9) % 1e9;
 			write_padded_number(fi, i64(y), 4);
 			write_padded_number(fi, i64(y), 4);
 			io.write_byte(fi.writer, '-');
 			io.write_byte(fi.writer, '-');
 			write_padded_number(fi, i64(mon), 2);
 			write_padded_number(fi, i64(mon), 2);
@@ -1403,7 +1403,7 @@ fmt_value :: proc(fi: ^Info, v: any, verb: rune) {
 			io.write_byte(fi.writer, ':');
 			io.write_byte(fi.writer, ':');
 			write_padded_number(fi, i64(s), 2);
 			write_padded_number(fi, i64(s), 2);
 			io.write_byte(fi.writer, '.');
 			io.write_byte(fi.writer, '.');
-			write_padded_number(fi, i64(ns), 9);
+			write_padded_number(fi, (ns), 9);
 			io.write_string(fi.writer, " +0000 UTC");
 			io.write_string(fi.writer, " +0000 UTC");
 			return;
 			return;
 		}
 		}
@@ -1842,7 +1842,7 @@ fmt_value :: proc(fi: ^Info, v: any, verb: rune) {
 		case u32:  tag = i64(i);
 		case u32:  tag = i64(i);
 		case i32:  tag = i64(i);
 		case i32:  tag = i64(i);
 		case u64:  tag = i64(i);
 		case u64:  tag = i64(i);
-		case i64:  tag = i64(i);
+		case i64:  tag = i;
 		case: panic("Invalid union tag type");
 		case: panic("Invalid union tag type");
 		}
 		}
 		assert(tag >= 0);
 		assert(tag >= 0);
@@ -2014,7 +2014,7 @@ fmt_arg :: proc(fi: ^Info, arg: any, verb: rune) {
 	base_arg := arg;
 	base_arg := arg;
 	base_arg.id = runtime.typeid_base(base_arg.id);
 	base_arg.id = runtime.typeid_base(base_arg.id);
 	switch a in base_arg {
 	switch a in base_arg {
-	case bool:       fmt_bool(fi, bool(a), verb);
+	case bool:       fmt_bool(fi, a, verb);
 	case b8:         fmt_bool(fi, bool(a), verb);
 	case b8:         fmt_bool(fi, bool(a), verb);
 	case b16:        fmt_bool(fi, bool(a), verb);
 	case b16:        fmt_bool(fi, bool(a), verb);
 	case b32:        fmt_bool(fi, bool(a), verb);
 	case b32:        fmt_bool(fi, bool(a), verb);
@@ -2045,7 +2045,7 @@ fmt_arg :: proc(fi: ^Info, arg: any, verb: rune) {
 	case i32:     fmt_int(fi, u64(a), true,  32, verb);
 	case i32:     fmt_int(fi, u64(a), true,  32, verb);
 	case u32:     fmt_int(fi, u64(a), false, 32, verb);
 	case u32:     fmt_int(fi, u64(a), false, 32, verb);
 	case i64:     fmt_int(fi, u64(a), true,  64, verb);
 	case i64:     fmt_int(fi, u64(a), true,  64, verb);
-	case u64:     fmt_int(fi, u64(a), false, 64, verb);
+	case u64:     fmt_int(fi,     a,  false, 64, verb);
 	case int:     fmt_int(fi, u64(a), true,  8*size_of(int), verb);
 	case int:     fmt_int(fi, u64(a), true,  8*size_of(int), verb);
 	case uint:    fmt_int(fi, u64(a), false, 8*size_of(uint), verb);
 	case uint:    fmt_int(fi, u64(a), false, 8*size_of(uint), verb);
 	case uintptr: fmt_int(fi, u64(a), false, 8*size_of(uintptr), verb);
 	case uintptr: fmt_int(fi, u64(a), false, 8*size_of(uintptr), verb);
@@ -2070,7 +2070,7 @@ fmt_arg :: proc(fi: ^Info, arg: any, verb: rune) {
 	case u64be:     fmt_int(fi, u64(a), false, 64, verb);
 	case u64be:     fmt_int(fi, u64(a), false, 64, verb);
 
 
 	case i128:     fmt_int_128(fi, u128(a), true,  128, verb);
 	case i128:     fmt_int_128(fi, u128(a), true,  128, verb);
-	case u128:     fmt_int_128(fi, u128(a), false, 128, verb);
+	case u128:     fmt_int_128(fi,       a, false, 128, verb);
 
 
 	case i128le:   fmt_int_128(fi, u128(a), true,  128, verb);
 	case i128le:   fmt_int_128(fi, u128(a), true,  128, verb);
 	case u128le:   fmt_int_128(fi, u128(a), false, 128, verb);
 	case u128le:   fmt_int_128(fi, u128(a), false, 128, verb);

+ 1 - 1
core/io/io.odin

@@ -290,7 +290,7 @@ write_byte :: proc{
 };
 };
 
 
 write_byte_to_byte_writer :: proc(w: Byte_Writer, c: byte) -> Error {
 write_byte_to_byte_writer :: proc(w: Byte_Writer, c: byte) -> Error {
-	return _write_byte(auto_cast w, c);
+	return _write_byte(w, c);
 }
 }
 
 
 write_byte_to_writer :: proc(w: Writer, c: byte) -> Error {
 write_byte_to_writer :: proc(w: Writer, c: byte) -> Error {

+ 1 - 1
core/io/util.odin

@@ -4,7 +4,7 @@ import "core:strconv"
 
 
 write_u64 :: proc(w: Writer, i: u64, base: int = 10) -> (n: int, err: Error) {
 write_u64 :: proc(w: Writer, i: u64, base: int = 10) -> (n: int, err: Error) {
 	buf: [32]byte;
 	buf: [32]byte;
-	s := strconv.append_bits(buf[:], u64(i), base, false, 64, strconv.digits, nil);
+	s := strconv.append_bits(buf[:], i, base, false, 64, strconv.digits, nil);
 	return write_string(w, s);
 	return write_string(w, s);
 }
 }
 write_i64 :: proc(w: Writer, i: i64, base: int = 10) -> (n: int, err: Error) {
 write_i64 :: proc(w: Writer, i: i64, base: int = 10) -> (n: int, err: Error) {

+ 4 - 4
core/math/bits/bits.odin

@@ -65,13 +65,13 @@ leading_zeros_u64 :: proc(i: u64) -> int {
 
 
 
 
 byte_swap_u16 :: proc(x: u16) -> u16 {
 byte_swap_u16 :: proc(x: u16) -> u16 {
-	return u16(runtime.bswap_16(u16(x)));
+	return runtime.bswap_16(x);
 }
 }
 byte_swap_u32 :: proc(x: u32) -> u32 {
 byte_swap_u32 :: proc(x: u32) -> u32 {
-	return u32(runtime.bswap_32(u32(x)));
+	return runtime.bswap_32(x);
 }
 }
 byte_swap_u64 :: proc(x: u64) -> u64 {
 byte_swap_u64 :: proc(x: u64) -> u64 {
-	return u64(runtime.bswap_64(u64(x)));
+	return runtime.bswap_64(x);
 }
 }
 byte_swap_i16 :: proc(x: i16) -> i16 {
 byte_swap_i16 :: proc(x: i16) -> i16 {
 	return i16(runtime.bswap_16(u16(x)));
 	return i16(runtime.bswap_16(u16(x)));
@@ -83,7 +83,7 @@ byte_swap_i64 :: proc(x: i64) -> i64 {
 	return i64(runtime.bswap_64(u64(x)));
 	return i64(runtime.bswap_64(u64(x)));
 }
 }
 byte_swap_u128 :: proc(x: u128) -> u128 {
 byte_swap_u128 :: proc(x: u128) -> u128 {
-	return u128(runtime.bswap_128(u128(x)));
+	return runtime.bswap_128(x);
 }
 }
 byte_swap_i128 :: proc(x: i128) -> i128 {
 byte_swap_i128 :: proc(x: i128) -> i128 {
 	return i128(runtime.bswap_128(u128(x)));
 	return i128(runtime.bswap_128(u128(x)));

+ 9 - 9
core/mem/allocators.odin

@@ -203,7 +203,7 @@ size := size;
 		old_ptr := uintptr(old_memory);
 		old_ptr := uintptr(old_memory);
 
 
 		if s.prev_allocation == 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;
 			s.prev_allocation = nil;
 			return nil;
 			return nil;
 		}
 		}
@@ -319,8 +319,8 @@ stack_allocator_proc :: proc(allocator_data: rawptr, mode: Allocator_Mode,
 
 
 		next_addr := curr_addr + uintptr(padding);
 		next_addr := curr_addr + uintptr(padding);
 		header := (^Stack_Allocation_Header)(next_addr - size_of(Stack_Allocation_Header));
 		header := (^Stack_Allocation_Header)(next_addr - size_of(Stack_Allocation_Header));
-		header.padding = auto_cast padding;
-		header.prev_offset = auto_cast s.prev_offset;
+		header.padding = padding;
+		header.prev_offset = s.prev_offset;
 
 
 		s.curr_offset += size;
 		s.curr_offset += size;
 
 
@@ -352,12 +352,12 @@ stack_allocator_proc :: proc(allocator_data: rawptr, mode: Allocator_Mode,
 		header := (^Stack_Allocation_Header)(curr_addr - size_of(Stack_Allocation_Header));
 		header := (^Stack_Allocation_Header)(curr_addr - size_of(Stack_Allocation_Header));
 		old_offset := int(curr_addr - uintptr(header.padding) - uintptr(raw_data(s.data)));
 		old_offset := int(curr_addr - uintptr(header.padding) - uintptr(raw_data(s.data)));
 
 
-		if old_offset != int(header.prev_offset) {
+		if old_offset != header.prev_offset {
 			panic("Out of order stack allocator free");
 			panic("Out of order stack allocator free");
 		}
 		}
 
 
-		s.curr_offset = int(old_offset);
-		s.prev_offset = int(header.prev_offset);
+		s.curr_offset = old_offset;
+		s.prev_offset = header.prev_offset;
 
 
 
 
 	case .Free_All:
 	case .Free_All:
@@ -391,7 +391,7 @@ stack_allocator_proc :: proc(allocator_data: rawptr, mode: Allocator_Mode,
 		header := (^Stack_Allocation_Header)(curr_addr - size_of(Stack_Allocation_Header));
 		header := (^Stack_Allocation_Header)(curr_addr - size_of(Stack_Allocation_Header));
 		old_offset := int(curr_addr - uintptr(header.padding) - uintptr(raw_data(s.data)));
 		old_offset := int(curr_addr - uintptr(header.padding) - uintptr(raw_data(s.data)));
 
 
-		if old_offset != int(header.prev_offset) {
+		if old_offset != header.prev_offset {
 			ptr := raw_alloc(s, size, alignment);
 			ptr := raw_alloc(s, size, alignment);
 			copy(ptr, old_memory, min(old_size, size));
 			copy(ptr, old_memory, min(old_size, size));
 			return ptr;
 			return ptr;
@@ -504,7 +504,7 @@ small_stack_allocator_proc :: proc(allocator_data: rawptr, mode: Allocator_Mode,
 		header := (^Small_Stack_Allocation_Header)(curr_addr - size_of(Small_Stack_Allocation_Header));
 		header := (^Small_Stack_Allocation_Header)(curr_addr - size_of(Small_Stack_Allocation_Header));
 		old_offset := int(curr_addr - uintptr(header.padding) - uintptr(raw_data(s.data)));
 		old_offset := int(curr_addr - uintptr(header.padding) - uintptr(raw_data(s.data)));
 
 
-		s.offset = int(old_offset);
+		s.offset = old_offset;
 
 
 	case .Free_All:
 	case .Free_All:
 		s.offset = 0;
 		s.offset = 0;
@@ -838,7 +838,7 @@ Tracking_Allocator_Entry :: struct {
 }
 }
 Tracking_Allocator_Bad_Free_Entry :: struct {
 Tracking_Allocator_Bad_Free_Entry :: struct {
 	memory:   rawptr,
 	memory:   rawptr,
-	location: runtime.Source_Code_Location,	
+	location: runtime.Source_Code_Location,
 }
 }
 Tracking_Allocator :: struct {
 Tracking_Allocator :: struct {
 	backing:           Allocator,
 	backing:           Allocator,

+ 1 - 2
core/mem/mem.odin

@@ -263,8 +263,7 @@ align_formula :: proc(size, align: int) -> int {
 }
 }
 
 
 calc_padding_with_header :: proc(ptr: uintptr, align: uintptr, header_size: int) -> int {
 calc_padding_with_header :: proc(ptr: uintptr, align: uintptr, header_size: int) -> int {
-	p := uintptr(ptr);
-	a := uintptr(align);
+	p, a := ptr, align;
 	modulo := p & (a-1);
 	modulo := p & (a-1);
 
 
 	padding := uintptr(0);
 	padding := uintptr(0);

+ 3 - 3
core/os/file_windows.odin

@@ -27,7 +27,7 @@ open :: proc(path: string, mode: int = O_RDONLY, perm: int = 0) -> (Handle, Errn
 		access |= win32.FILE_GENERIC_WRITE;
 		access |= win32.FILE_GENERIC_WRITE;
 	}
 	}
 
 
-	share_mode := u32(win32.FILE_SHARE_READ|win32.FILE_SHARE_WRITE);
+	share_mode := win32.FILE_SHARE_READ|win32.FILE_SHARE_WRITE;
 	sa: ^win32.SECURITY_ATTRIBUTES = nil;
 	sa: ^win32.SECURITY_ATTRIBUTES = nil;
 	sa_inherit := win32.SECURITY_ATTRIBUTES{nLength = size_of(win32.SECURITY_ATTRIBUTES), bInheritHandle = true};
 	sa_inherit := win32.SECURITY_ATTRIBUTES{nLength = size_of(win32.SECURITY_ATTRIBUTES), bInheritHandle = true};
 	if mode&O_CLOEXEC == 0 {
 	if mode&O_CLOEXEC == 0 {
@@ -48,7 +48,7 @@ open :: proc(path: string, mode: int = O_RDONLY, perm: int = 0) -> (Handle, Errn
 		create_mode = win32.OPEN_EXISTING;
 		create_mode = win32.OPEN_EXISTING;
 	}
 	}
 	wide_path := win32.utf8_to_wstring(path);
 	wide_path := win32.utf8_to_wstring(path);
-	handle := Handle(win32.CreateFileW(auto_cast wide_path, access, share_mode, sa, create_mode, win32.FILE_ATTRIBUTE_NORMAL|win32.FILE_FLAG_BACKUP_SEMANTICS, nil));
+	handle := Handle(win32.CreateFileW(wide_path, access, share_mode, sa, create_mode, win32.FILE_ATTRIBUTE_NORMAL|win32.FILE_FLAG_BACKUP_SEMANTICS, nil));
 	if handle != INVALID_HANDLE {
 	if handle != INVALID_HANDLE {
 		return handle, ERROR_NONE;
 		return handle, ERROR_NONE;
 	}
 	}
@@ -107,7 +107,7 @@ read :: proc(fd: Handle, data: []byte) -> (int, Errno) {
 
 
 	for total_read < length {
 	for total_read < length {
 		remaining := length - total_read;
 		remaining := length - total_read;
-		to_read := win32.DWORD(min(u32(remaining), MAX_RW));
+		to_read := min(win32.DWORD(remaining), MAX_RW);
 
 
 		e := win32.ReadFile(win32.HANDLE(fd), &data[total_read], to_read, &single_read_length, nil);
 		e := win32.ReadFile(win32.HANDLE(fd), &data[total_read], to_read, &single_read_length, nil);
 		if single_read_length <= 0 || !e {
 		if single_read_length <= 0 || !e {

+ 1 - 1
core/os/os_windows.odin

@@ -79,7 +79,7 @@ last_write_time_by_name :: proc(name: string) -> (File_Time, Errno) {
 	data: win32.WIN32_FILE_ATTRIBUTE_DATA;
 	data: win32.WIN32_FILE_ATTRIBUTE_DATA;
 
 
 	wide_path := win32.utf8_to_wstring(name);
 	wide_path := win32.utf8_to_wstring(name);
-	if !win32.GetFileAttributesExW(auto_cast wide_path, win32.GetFileExInfoStandard, &data) {
+	if !win32.GetFileAttributesExW(wide_path, win32.GetFileExInfoStandard, &data) {
 		return 0, Errno(win32.GetLastError());
 		return 0, Errno(win32.GetLastError());
 	}
 	}
 
 

+ 2 - 2
core/os/stat_windows.odin

@@ -68,13 +68,13 @@ _stat :: proc(name: string, create_file_attributes: u32, allocator := context.al
 
 
 
 
 lstat :: proc(name: string, allocator := context.allocator) -> (File_Info, Errno) {
 lstat :: proc(name: string, allocator := context.allocator) -> (File_Info, Errno) {
-	attrs := u32(win32.FILE_FLAG_BACKUP_SEMANTICS);
+	attrs := win32.FILE_FLAG_BACKUP_SEMANTICS;
 	attrs |= win32.FILE_FLAG_OPEN_REPARSE_POINT;
 	attrs |= win32.FILE_FLAG_OPEN_REPARSE_POINT;
 	return _stat(name, attrs, allocator);
 	return _stat(name, attrs, allocator);
 }
 }
 
 
 stat :: proc(name: string, allocator := context.allocator) -> (File_Info, Errno) {
 stat :: proc(name: string, allocator := context.allocator) -> (File_Info, Errno) {
-	attrs := u32(win32.FILE_FLAG_BACKUP_SEMANTICS);
+	attrs := win32.FILE_FLAG_BACKUP_SEMANTICS;
 	return _stat(name, attrs, allocator);
 	return _stat(name, attrs, allocator);
 }
 }
 
 

+ 42 - 42
core/reflect/reflect.odin

@@ -597,7 +597,7 @@ union_variant_typeid :: proc(a: any) -> typeid {
 		case u32:  tag = i64(i);
 		case u32:  tag = i64(i);
 		case i32:  tag = i64(i);
 		case i32:  tag = i64(i);
 		case u64:  tag = i64(i);
 		case u64:  tag = i64(i);
-		case i64:  tag = i64(i);
+		case i64:  tag = i;
 		case: unimplemented();
 		case: unimplemented();
 		}
 		}
 
 
@@ -633,7 +633,7 @@ get_union_variant_raw_tag :: proc(a: any) -> i64 {
 		case u32:  tag = i64(i);
 		case u32:  tag = i64(i);
 		case i32:  tag = i64(i);
 		case i32:  tag = i64(i);
 		case u64:  tag = i64(i);
 		case u64:  tag = i64(i);
-		case i64:  tag = i64(i);
+		case i64:  tag = i;
 		case: unimplemented();
 		case: unimplemented();
 		}
 		}
 
 
@@ -664,7 +664,7 @@ set_union_variant_raw_tag :: proc(a: any, tag: i64) {
 		case u32:  i = u32(tag);
 		case u32:  i = u32(tag);
 		case i32:  i = i32(tag);
 		case i32:  i = i32(tag);
 		case u64:  i = u64(tag);
 		case u64:  i = u64(tag);
-		case i64:  i = i64(tag);
+		case i64:  i = tag;
 		case: unimplemented();
 		case: unimplemented();
 		}
 		}
 
 
@@ -744,7 +744,7 @@ as_bool :: proc(a: any) -> (value: bool, valid: bool) {
 	case Type_Info_Boolean:
 	case Type_Info_Boolean:
 		valid = true;
 		valid = true;
 		switch v in a {
 		switch v in a {
-		case bool: value = bool(v);
+		case bool: value = v;
 		case b8:   value = bool(v);
 		case b8:   value = bool(v);
 		case b16:  value = bool(v);
 		case b16:  value = bool(v);
 		case b32:  value = bool(v);
 		case b32:  value = bool(v);
@@ -783,7 +783,7 @@ as_i64 :: proc(a: any) -> (value: i64, valid: bool) {
 		case i8:      value = i64(v);
 		case i8:      value = i64(v);
 		case i16:     value = i64(v);
 		case i16:     value = i64(v);
 		case i32:     value = i64(v);
 		case i32:     value = i64(v);
-		case i64:     value = i64(v);
+		case i64:     value =      v;
 		case i128:    value = i64(v);
 		case i128:    value = i64(v);
 		case int:     value = i64(v);
 		case int:     value = i64(v);
 
 
@@ -825,23 +825,23 @@ as_i64 :: proc(a: any) -> (value: i64, valid: bool) {
 	case Type_Info_Float:
 	case Type_Info_Float:
 		valid = true;
 		valid = true;
 		switch v in a {
 		switch v in a {
-		case f32:   value = i64(f32(v));
-		case f64:   value = i64(f64(v));
-		case f32le: value = i64(f32(v));
-		case f64le: value = i64(f64(v));
-		case f32be: value = i64(f32(v));
-		case f64be: value = i64(f64(v));
+		case f32:   value = i64(v);
+		case f64:   value = i64(v);
+		case f32le: value = i64(v);
+		case f64le: value = i64(v);
+		case f32be: value = i64(v);
+		case f64be: value = i64(v);
 		case: valid = false;
 		case: valid = false;
 		}
 		}
 
 
 	case Type_Info_Boolean:
 	case Type_Info_Boolean:
 		valid = true;
 		valid = true;
 		switch v in a {
 		switch v in a {
-		case bool: value = i64(bool(v));
-		case b8:   value = i64(bool(v));
-		case b16:  value = i64(bool(v));
-		case b32:  value = i64(bool(v));
-		case b64:  value = i64(bool(v));
+		case bool: value = i64(v);
+		case b8:   value = i64(v);
+		case b16:  value = i64(v);
+		case b32:  value = i64(v);
+		case b64:  value = i64(v);
 		case: valid = false;
 		case: valid = false;
 		}
 		}
 
 
@@ -897,7 +897,7 @@ as_u64 :: proc(a: any) -> (value: u64, valid: bool) {
 		case u8:     value = u64(v);
 		case u8:     value = u64(v);
 		case u16:    value = u64(v);
 		case u16:    value = u64(v);
 		case u32:    value = u64(v);
 		case u32:    value = u64(v);
-		case u64:    value = u64(v);
+		case u64:    value =    (v);
 		case u128:   value = u64(v);
 		case u128:   value = u64(v);
 		case uint:   value = u64(v);
 		case uint:   value = u64(v);
 		case uintptr:value = u64(v);
 		case uintptr:value = u64(v);
@@ -932,23 +932,23 @@ as_u64 :: proc(a: any) -> (value: u64, valid: bool) {
 	case Type_Info_Float:
 	case Type_Info_Float:
 		valid = true;
 		valid = true;
 		switch v in a {
 		switch v in a {
-		case f32:   value = u64(f32(v));
-		case f64:   value = u64(f64(v));
-		case f32le: value = u64(f32(v));
-		case f64le: value = u64(f64(v));
-		case f32be: value = u64(f32(v));
-		case f64be: value = u64(f64(v));
+		case f32:   value = u64(v);
+		case f64:   value = u64(v);
+		case f32le: value = u64(v);
+		case f64le: value = u64(v);
+		case f32be: value = u64(v);
+		case f64be: value = u64(v);
 		case: valid = false;
 		case: valid = false;
 		}
 		}
 
 
 	case Type_Info_Boolean:
 	case Type_Info_Boolean:
 		valid = true;
 		valid = true;
 		switch v in a {
 		switch v in a {
-		case bool: value = u64(bool(v));
-		case b8:   value = u64(bool(v));
-		case b16:  value = u64(bool(v));
-		case b32:  value = u64(bool(v));
-		case b64:  value = u64(bool(v));
+		case bool: value = u64(v);
+		case b8:   value = u64(v);
+		case b16:  value = u64(v);
+		case b32:  value = u64(v);
+		case b64:  value = u64(v);
 		case: valid = false;
 		case: valid = false;
 		}
 		}
 
 
@@ -1037,23 +1037,23 @@ as_f64 :: proc(a: any) -> (value: f64, valid: bool) {
 	case Type_Info_Float:
 	case Type_Info_Float:
 		valid = true;
 		valid = true;
 		switch v in a {
 		switch v in a {
-		case f32:   value = f64(f32(v));
-		case f64:   value = f64(f64(v));
-		case f32le: value = f64(f32(v));
-		case f64le: value = f64(f64(v));
-		case f32be: value = f64(f32(v));
-		case f64be: value = f64(f64(v));
+		case f32:   value = f64(v);
+		case f64:   value =    (v);
+		case f32le: value = f64(v);
+		case f64le: value = f64(v);
+		case f32be: value = f64(v);
+		case f64be: value = f64(v);
 		case: valid = false;
 		case: valid = false;
 		}
 		}
 
 
 	case Type_Info_Boolean:
 	case Type_Info_Boolean:
 		valid = true;
 		valid = true;
 		switch v in a {
 		switch v in a {
-		case bool: value = f64(i32(bool(v)));
-		case b8:   value = f64(i32(bool(v)));
-		case b16:  value = f64(i32(bool(v)));
-		case b32:  value = f64(i32(bool(v)));
-		case b64:  value = f64(i32(bool(v)));
+		case bool: value = f64(i32(v));
+		case b8:   value = f64(i32(v));
+		case b16:  value = f64(i32(v));
+		case b32:  value = f64(i32(v));
+		case b64:  value = f64(i32(v));
 		case: valid = false;
 		case: valid = false;
 		}
 		}
 
 
@@ -1066,7 +1066,7 @@ as_f64 :: proc(a: any) -> (value: f64, valid: bool) {
 			}
 			}
 		case complex128:
 		case complex128:
 			if imag(v) == 0 {
 			if imag(v) == 0 {
-				value = f64(real(v));
+				value = real(v);
 				valid = true;
 				valid = true;
 			}
 			}
 		}
 		}
@@ -1080,7 +1080,7 @@ as_f64 :: proc(a: any) -> (value: f64, valid: bool) {
 			}
 			}
 		case quaternion256:
 		case quaternion256:
 			if imag(v) == 0 && jmag(v) == 0 && kmag(v) == 0 {
 			if imag(v) == 0 && jmag(v) == 0 && kmag(v) == 0 {
-				value = f64(real(v));
+				value = real(v);
 				valid = true;
 				valid = true;
 			}
 			}
 		}
 		}
@@ -1100,7 +1100,7 @@ as_string :: proc(a: any) -> (value: string, valid: bool) {
 	case Type_Info_String:
 	case Type_Info_String:
 		valid = true;
 		valid = true;
 		switch v in a {
 		switch v in a {
-		case string:  value = string(v);
+		case string:  value = v;
 		case cstring: value = string(v);
 		case cstring: value = string(v);
 		case: valid = false;
 		case: valid = false;
 		}
 		}

+ 1 - 1
core/runtime/default_allocators.odin

@@ -127,7 +127,7 @@ default_temp_allocator_proc :: proc(allocator_data: rawptr, mode: Allocator_Mode
 		old_ptr := uintptr(old_memory);
 		old_ptr := uintptr(old_memory);
 
 
 		if s.prev_allocation == 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;
 			s.prev_allocation = nil;
 			return nil;
 			return nil;
 		}
 		}

+ 6 - 6
core/runtime/dynamic_map_internal.odin

@@ -159,14 +159,14 @@ __get_map_header :: proc "contextless" (m: ^$T/map[$K]$V) -> Map_Header {
 
 
 	header.equal = intrinsics.type_equal_proc(K);
 	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;
 	return header;
 }
 }

+ 4 - 4
core/runtime/error_checks.odin

@@ -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_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_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_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_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);
 }
 }

+ 2 - 2
core/runtime/internal.odin

@@ -195,7 +195,7 @@ memory_compare :: proc "contextless" (a, b: rawptr, n: int) -> int #no_bounds_ch
 	n := uintptr(n);
 	n := uintptr(n);
 
 
 	SU :: size_of(uintptr);
 	SU :: size_of(uintptr);
-	fast := uintptr(n/SU + 1);
+	fast := n/SU + 1;
 	offset := (fast-1)*SU;
 	offset := (fast-1)*SU;
 	curr_block := uintptr(0);
 	curr_block := uintptr(0);
 	if n < SU {
 	if n < SU {
@@ -232,7 +232,7 @@ memory_compare_zero :: proc "contextless" (a: rawptr, n: int) -> int #no_bounds_
 	n := uintptr(n);
 	n := uintptr(n);
 
 
 	SU :: size_of(uintptr);
 	SU :: size_of(uintptr);
-	fast := uintptr(n/SU + 1);
+	fast := n/SU + 1;
 	offset := (fast-1)*SU;
 	offset := (fast-1)*SU;
 	curr_block := uintptr(0);
 	curr_block := uintptr(0);
 	if n < SU {
 	if n < SU {

+ 5 - 5
core/runtime/internal_windows.odin

@@ -63,8 +63,8 @@ fixdfti :: proc(a: u64) -> i128 {
     aRep := a;
     aRep := a;
     aAbs := aRep & absMask;
     aAbs := aRep & absMask;
     sign := i128(-1 if aRep & signBit != 0 else 1);
     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 is negative, the result is zero.
     if exponent < 0 {
     if exponent < 0 {
@@ -103,7 +103,7 @@ floattidf :: proc(a: i128) -> f64 {
     s := a >> (N-1);
     s := a >> (N-1);
     a = (a ~ s) - s;
     a = (a ~ s) - s;
     sd: = N - _clz_i128(a);  // number of significant digits
     sd: = N - _clz_i128(a);  // number of significant digits
-    e := u32(sd - 1);        // exponent 
+    e := u32(sd - 1);        // exponent
     if sd > DBL_MANT_DIG {
     if sd > DBL_MANT_DIG {
         switch sd {
         switch sd {
         case DBL_MANT_DIG + 1:
         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);
                 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;
         a >>= 2;
 
 
         if a & (1 << DBL_MANT_DIG) != 0 {
         if a & (1 << DBL_MANT_DIG) != 0 {

+ 2 - 2
core/strconv/integers.odin

@@ -30,7 +30,7 @@ is_integer_negative :: proc(x: u64, is_signed: bool, bit_size: int) -> (u: u64,
 		case 64:
 		case 64:
 			i := i64(u);
 			i := i64(u);
 			neg = i < 0;
 			neg = i < 0;
-			u = u64(abs(i64(i)));
+			u = u64(abs(i));
 		case:
 		case:
 			panic("is_integer_negative: Unknown integer size");
 			panic("is_integer_negative: Unknown integer size");
 		}
 		}
@@ -105,7 +105,7 @@ is_integer_negative_128 :: proc(x: u128, is_signed: bool, bit_size: int) -> (u:
 		case 128:
 		case 128:
 			i := i128(u);
 			i := i128(u);
 			neg = i < 0;
 			neg = i < 0;
-			u = u128(abs(i128(i)));
+			u = u128(abs(i));
 		case:
 		case:
 			panic("is_integer_negative: Unknown integer size");
 			panic("is_integer_negative: Unknown integer size");
 		}
 		}

+ 2 - 2
core/strconv/strconv.odin

@@ -231,7 +231,7 @@ parse_u64_maybe_prefixed :: proc(str: string) -> (value: u64, ok: bool) {
 			break;
 			break;
 		}
 		}
 		value *= base;
 		value *= base;
-		value += u64(v);
+		value += v;
 		i += 1;
 		i += 1;
 	}
 	}
 	s = s[i:];
 	s = s[i:];
@@ -433,7 +433,7 @@ append_bool :: proc(buf: []byte, b: bool) -> string {
 }
 }
 
 
 append_uint :: proc(buf: []byte, u: u64, base: int) -> string {
 append_uint :: proc(buf: []byte, u: u64, base: int) -> string {
-	return append_bits(buf, u64(u), base, false, 8*size_of(uint), digits, nil);
+	return append_bits(buf, u, base, false, 8*size_of(uint), digits, nil);
 }
 }
 append_int :: proc(buf: []byte, i: i64, base: int) -> string {
 append_int :: proc(buf: []byte, i: i64, base: int) -> string {
 	return append_bits(buf, u64(i), base, true, 8*size_of(int), digits, nil);
 	return append_bits(buf, u64(i), base, true, 8*size_of(int), digits, nil);

+ 1 - 1
core/strings/builder.odin

@@ -385,7 +385,7 @@ write_escaped_rune_writer :: proc(w: io.Writer, r: rune, quote: byte, html_safe
 
 
 write_u64 :: proc(b: ^Builder, i: u64, base: int = 10) -> (n: int) {
 write_u64 :: proc(b: ^Builder, i: u64, base: int = 10) -> (n: int) {
 	buf: [32]byte;
 	buf: [32]byte;
-	s := strconv.append_bits(buf[:], u64(i), base, false, 64, strconv.digits, nil);
+	s := strconv.append_bits(buf[:], i, base, false, 64, strconv.digits, nil);
 	return write_string(b, s);
 	return write_string(b, s);
 }
 }
 write_i64 :: proc(b: ^Builder, i: i64, base: int = 10) -> (n: int) {
 write_i64 :: proc(b: ^Builder, i: i64, base: int = 10) -> (n: int) {

+ 1 - 1
core/sync/channel_windows.odin

@@ -5,7 +5,7 @@ import win32 "core:sys/windows"
 import "core:time"
 import "core:time"
 
 
 raw_channel_wait_queue_wait_on :: proc(state: ^uintptr, timeout: time.Duration) {
 raw_channel_wait_queue_wait_on :: proc(state: ^uintptr, timeout: time.Duration) {
-	ms := win32.DWORD(win32.INFINITE);
+	ms: win32.DWORD = win32.INFINITE;
 	if max(time.Duration) != SELECT_MAX_TIMEOUT {
 	if max(time.Duration) != SELECT_MAX_TIMEOUT {
 		ms = win32.DWORD((max(time.duration_nanoseconds(timeout), 0) + 999999)/1000000);
 		ms = win32.DWORD((max(time.duration_nanoseconds(timeout), 0) + 999999)/1000000);
 	}
 	}

+ 1 - 1
core/sys/win32/comdlg32.odin

@@ -69,7 +69,7 @@ foreign comdlg32 {
 
 
 OPEN_TITLE :: "Select file to open";
 OPEN_TITLE :: "Select file to open";
 OPEN_FLAGS :: u32(OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST);
 OPEN_FLAGS :: u32(OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST);
-OPEN_FLAGS_MULTI :: u32(OPEN_FLAGS | OFN_ALLOWMULTISELECT | OFN_EXPLORER);
+OPEN_FLAGS_MULTI :: OPEN_FLAGS | OFN_ALLOWMULTISELECT | OFN_EXPLORER;
 
 
 SAVE_TITLE :: "Select file to save";
 SAVE_TITLE :: "Select file to save";
 SAVE_FLAGS :: u32(OFN_OVERWRITEPROMPT | OFN_EXPLORER);
 SAVE_FLAGS :: u32(OFN_OVERWRITEPROMPT | OFN_EXPLORER);

+ 4 - 4
core/sys/windows/kernel32.odin

@@ -293,10 +293,10 @@ SECTION_EXTEND_SIZE          :: DWORD(0x0010);
 SECTION_ALL_ACCESS           :: STANDARD_RIGHTS_REQUIRED | SECTION_QUERY | SECTION_MAP_WRITE | SECTION_MAP_READ | SECTION_MAP_EXECUTE | SECTION_EXTEND_SIZE;
 SECTION_ALL_ACCESS           :: STANDARD_RIGHTS_REQUIRED | SECTION_QUERY | SECTION_MAP_WRITE | SECTION_MAP_READ | SECTION_MAP_EXECUTE | SECTION_EXTEND_SIZE;
 SECTION_MAP_EXECUTE_EXPLICIT :: DWORD(0x0020);
 SECTION_MAP_EXECUTE_EXPLICIT :: DWORD(0x0020);
 
 
-FILE_MAP_WRITE           :: DWORD(SECTION_MAP_WRITE);
-FILE_MAP_READ            :: DWORD(SECTION_MAP_READ);
-FILE_MAP_ALL_ACCESS      :: DWORD(SECTION_ALL_ACCESS);
-FILE_MAP_EXECUTE         :: DWORD(SECTION_MAP_EXECUTE_EXPLICIT);
+FILE_MAP_WRITE           :: SECTION_MAP_WRITE;
+FILE_MAP_READ            :: SECTION_MAP_READ;
+FILE_MAP_ALL_ACCESS      :: SECTION_ALL_ACCESS;
+FILE_MAP_EXECUTE         :: SECTION_MAP_EXECUTE_EXPLICIT;
 FILE_MAP_COPY            :: DWORD(0x00000001);
 FILE_MAP_COPY            :: DWORD(0x00000001);
 FILE_MAP_RESERVE         :: DWORD(0x80000000);
 FILE_MAP_RESERVE         :: DWORD(0x80000000);
 FILE_MAP_TARGETS_INVALID :: DWORD(0x40000000);
 FILE_MAP_TARGETS_INVALID :: DWORD(0x40000000);

+ 2 - 2
core/sys/windows/util.odin

@@ -22,7 +22,7 @@ utf8_to_utf16 :: proc(s: string, allocator := context.temp_allocator) -> []u16 {
 
 
 	text := make([]u16, n+1, allocator);
 	text := make([]u16, n+1, allocator);
 
 
-	n1 := MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, cstr, i32(len(s)), raw_data(text), i32(n));
+	n1 := MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, cstr, i32(len(s)), raw_data(text), n);
 	if n1 == 0 {
 	if n1 == 0 {
 		delete(text, allocator);
 		delete(text, allocator);
 		return nil;
 		return nil;
@@ -36,7 +36,7 @@ utf8_to_utf16 :: proc(s: string, allocator := context.temp_allocator) -> []u16 {
 }
 }
 utf8_to_wstring :: proc(s: string, allocator := context.temp_allocator) -> wstring {
 utf8_to_wstring :: proc(s: string, allocator := context.temp_allocator) -> wstring {
 	if res := utf8_to_utf16(s, allocator); res != nil {
 	if res := utf8_to_utf16(s, allocator); res != nil {
-		return wstring(&res[0]);
+		return &res[0];
 	}
 	}
 	return nil;
 	return nil;
 }
 }

+ 5 - 5
core/time/time.odin

@@ -174,16 +174,16 @@ time_add :: proc(t: Time, d: Duration) -> Time {
 
 
 ABSOLUTE_ZERO_YEAR :: i64(-292277022399); // Day is chosen so that 2001-01-01 is Monday in the calculations
 ABSOLUTE_ZERO_YEAR :: i64(-292277022399); // Day is chosen so that 2001-01-01 is Monday in the calculations
 ABSOLUTE_TO_INTERNAL :: i64(-9223371966579724800); // i64((ABSOLUTE_ZERO_YEAR - 1) * 365.2425 * SECONDS_PER_DAY);
 ABSOLUTE_TO_INTERNAL :: i64(-9223371966579724800); // i64((ABSOLUTE_ZERO_YEAR - 1) * 365.2425 * SECONDS_PER_DAY);
-INTERNAL_TO_ABSOLUTE :: i64(-ABSOLUTE_TO_INTERNAL);
+INTERNAL_TO_ABSOLUTE :: -ABSOLUTE_TO_INTERNAL;
 
 
 UNIX_TO_INTERNAL :: i64((1969*365 + 1969/4 - 1969/100 + 1969/400) * SECONDS_PER_DAY);
 UNIX_TO_INTERNAL :: i64((1969*365 + 1969/4 - 1969/100 + 1969/400) * SECONDS_PER_DAY);
-INTERNAL_TO_UNIX :: i64(-UNIX_TO_INTERNAL);
+INTERNAL_TO_UNIX :: -UNIX_TO_INTERNAL;
 
 
 WALL_TO_INTERNAL :: i64((1884*365 + 1884/4 - 1884/100 + 1884/400) * SECONDS_PER_DAY);
 WALL_TO_INTERNAL :: i64((1884*365 + 1884/4 - 1884/100 + 1884/400) * SECONDS_PER_DAY);
-INTERNAL_TO_WALL :: i64(- WALL_TO_INTERNAL);
+INTERNAL_TO_WALL :: -WALL_TO_INTERNAL;
 
 
-UNIX_TO_ABSOLUTE :: i64(UNIX_TO_INTERNAL + INTERNAL_TO_ABSOLUTE);
-ABSOLUTE_TO_UNIX :: i64(-UNIX_TO_ABSOLUTE);
+UNIX_TO_ABSOLUTE :: UNIX_TO_INTERNAL + INTERNAL_TO_ABSOLUTE;
+ABSOLUTE_TO_UNIX :: -UNIX_TO_ABSOLUTE;
 
 
 _is_leap_year :: proc(year: int) -> bool {
 _is_leap_year :: proc(year: int) -> bool {
 	return year%4 == 0 && (year%100 != 0 || year%400 == 0);
 	return year%4 == 0 && (year%100 != 0 || year%400 == 0);

+ 1 - 1
core/time/time_windows.odin

@@ -32,6 +32,6 @@ _tick_now :: proc() -> Tick {
 	now: win32.LARGE_INTEGER;
 	now: win32.LARGE_INTEGER;
 	win32.QueryPerformanceCounter(&now);
 	win32.QueryPerformanceCounter(&now);
 
 
-	_nsec := i64(mul_div_u64(i64(now), 1e9, i64(qpc_frequency)));
+	_nsec := mul_div_u64(i64(now), 1e9, i64(qpc_frequency));
 	return Tick{_nsec = _nsec};
 	return Tick{_nsec = _nsec};
 }
 }