From: Brendan Hansen Date: Tue, 7 Mar 2023 16:30:21 +0000 (-0600) Subject: added: variant of string.concat for appending single characters X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=199b5053f97746a40d704acb0ad909d917a4630b;p=onyx.git added: variant of string.concat for appending single characters --- diff --git a/core/math/math.onyx b/core/math/math.onyx index 2052125b..bbebea72 100644 --- a/core/math/math.onyx +++ b/core/math/math.onyx @@ -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, diff --git a/core/string/string.onyx b/core/string/string.onyx index d374ff2e..0b1b465b 100644 --- a/core/string/string.onyx +++ b/core/string/string.onyx @@ -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 {}