From: Brendan Hansen Date: Mon, 11 Jan 2021 18:59:26 +0000 (-0600) Subject: small cleanup with parameters being mutable now X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=283488ff151a4d04172bd9d01c4f1d1ad49335c7;p=onyx.git small cleanup with parameters being mutable now --- diff --git a/core/conv.onyx b/core/conv.onyx index 6ddd9caa..121be4fd 100644 --- a/core/conv.onyx +++ b/core/conv.onyx @@ -1,12 +1,10 @@ package core.conv -i64_to_str :: proc (n_: i64, base: u64, buf: [] u8) -> str { - n := cast(u64) n_; - +i64_to_str :: proc (n: i64, base: u64, buf: [] u8) -> str { is_neg := false; - if n_ < 0 && base == 10 { + if n < 0 && base == 10 { is_neg = true; - n = cast(u64) -n_; + n = -n; } c := ^buf[buf.count - 1]; @@ -16,7 +14,7 @@ i64_to_str :: proc (n_: i64, base: u64, buf: [] u8) -> str { BASE64_MAP := "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/"; while n > 0 { - m := n % base; + m := cast(u64) n % base; *c = BASE64_MAP[cast(u32) m]; len += 1; @@ -59,9 +57,8 @@ i64_to_str :: proc (n_: i64, base: u64, buf: [] u8) -> str { // NOTE: This is a big hack but it will work for now f64_to_str :: proc (f: f64, buf: [] u8) -> str { - a := f; - a *= 10000.0; - v := cast(i64) a; + f *= 10000.0; + v := cast(i64) f; len := 0; diff --git a/core/math.onyx b/core/math.onyx index 235cec4b..a0e19c5e 100644 --- a/core/math.onyx +++ b/core/math.onyx @@ -9,8 +9,7 @@ PI :: 3.14159265f; TAU :: 6.28318330f; // Simple taylor series approximation of sin(t) -sin :: proc (t_: f32) -> f32 { - t := t_; +sin :: proc (t: f32) -> f32 { while t >= PI do t -= TAU; while t <= -PI do t += TAU; @@ -32,8 +31,7 @@ sin :: proc (t_: f32) -> f32 { } // Simple taylor series approximation of cos(t) -cos :: proc (t_: f32) -> f32 { - t := t_; +cos :: proc (t: f32) -> f32 { while t >= PI do t -= TAU; while t <= -PI do t += TAU;