added: variant of string.concat for appending single characters
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Tue, 7 Mar 2023 16:30:21 +0000 (10:30 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Tue, 7 Mar 2023 16:30:21 +0000 (10:30 -0600)
core/math/math.onyx
core/string/string.onyx

index 2052125b8ae34209bc2e8c0f2899955a7641ae0a..bbebea727062b8e376176769077fcbfecaa8cda3 100644 (file)
@@ -136,7 +136,7 @@ atanh :: (t: $T) -> T {
 // are needed. Logarithms are implemented using a polynomial that is accurate in the range of
 // [1, 2], and then utilizes this identity for values outside of that range,
 //
-//      ln(x) = ln(2&n * v) = n * ln(2) + ln(v),   v is in [1, 2]
+//      ln(x) = ln(2^n * v) = n * ln(2) + ln(v),   v is in [1, 2]
 //
 
 // FIX: This definition is very wrong. It casts E to be whatever the type of the argument is,
index d374ff2ee989fba1666e9c43d27646ae378fa56e..0b1b465bf16b9cacf7a0d46f7311f75cefa8887f 100644 (file)
@@ -126,6 +126,16 @@ concat :: (into: &[..] u8, strings: ..str) -> str {
     return .{ into.data, into.count };
 }
 
+#overload
+concat :: (into: &[..] u8, chars: ..u8) -> str {
+    array.ensure_capacity(into, into.count + chars.count);
+    for c: chars {
+        memory.copy(into.data + into.count, cast(rawptr) &.[c], 1);
+        into.count += 1;
+    }
+    return .{ into.data, into.count };
+}
+
 
 contains :: #match #local {}