From 54a6637d38c5abd8a2b483d4505c9ea318b77dc0 Mon Sep 17 00:00:00 2001 From: Colin Davidson Date: Fri, 18 Feb 2022 20:50:49 -0800 Subject: Use the _unix_fstat pointer to avoid 144B copies on fileIO --- core/os/os_linux.odin | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/core/os/os_linux.odin b/core/os/os_linux.odin index 140b84d8a..4edfa46da 100644 --- a/core/os/os_linux.odin +++ b/core/os/os_linux.odin @@ -501,11 +501,13 @@ seek :: proc(fd: Handle, offset: i64, whence: int) -> (i64, Errno) { } file_size :: proc(fd: Handle) -> (i64, Errno) { - s, err := _fstat(fd) - if err != ERROR_NONE { - return 0, err - } - return max(s.size, 0), ERROR_NONE + // deliberately uninitialized; the syscall fills this buffer for us + s: OS_Stat = --- + result := _unix_fstat(fd, &s) + if result < 0 { + return 0, _get_errno(result) + } + return max(s.size, 0), ERROR_NONE } rename :: proc(old_path, new_path: string) -> Errno { -- cgit v1.2.3