small cleanup with parameters being mutable now
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 11 Jan 2021 18:59:26 +0000 (12:59 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 11 Jan 2021 18:59:26 +0000 (12:59 -0600)
core/conv.onyx
core/math.onyx

index 6ddd9caadf238afdeb48265d6142daa5f0afbd8b..121be4fd24663daaace81c78d54bb2db75ff033d 100644 (file)
@@ -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;
 
index 235cec4b70c918dc6b685130806ff669b7d791d8..a0e19c5e964a080dcbeb07e8cced3cb79c055b22 100644 (file)
@@ -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;