From dce176fa39b34acca49c965809cad97060bf5ff3 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Wed, 28 Feb 2024 18:24:59 +0000 Subject: [PATCH] Remove unnecessary use of `transmute` --- core/os/os.odin | 6 ++---- core/os/os2/file_util.odin | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/core/os/os.odin b/core/os/os.odin index c74712d4e..6d0e22a04 100644 --- a/core/os/os.odin +++ b/core/os/os.odin @@ -160,13 +160,11 @@ write_entire_file :: proc(name: string, data: []byte, truncate := true) -> (succ } write_ptr :: proc(fd: Handle, data: rawptr, len: int) -> (int, Errno) { - s := transmute([]byte)mem.Raw_Slice{data, len} - return write(fd, s) + return write(fd, ([^]byte)(data)[:len]) } read_ptr :: proc(fd: Handle, data: rawptr, len: int) -> (int, Errno) { - s := transmute([]byte)mem.Raw_Slice{data, len} - return read(fd, s) + return read(fd, ([^]byte)(data)[:len]) } heap_allocator_proc :: runtime.heap_allocator_proc diff --git a/core/os/os2/file_util.odin b/core/os/os2/file_util.odin index e52d53f08..11d1f688d 100644 --- a/core/os/os2/file_util.odin +++ b/core/os/os2/file_util.odin @@ -64,13 +64,11 @@ write_encoded_rune :: proc(f: ^File, r: rune) -> (n: int, err: Error) { write_ptr :: proc(f: ^File, data: rawptr, len: int) -> (n: int, err: Error) { - s := transmute([]byte)mem.Raw_Slice{data, len} - return write(f, s) + return write(f, ([^]byte)(data)[:len]) } read_ptr :: proc(f: ^File, data: rawptr, len: int) -> (n: int, err: Error) { - s := transmute([]byte)mem.Raw_Slice{data, len} - return read(f, s) + return read(f, ([^]byte)(data)[:len]) }