From 199b5053f97746a40d704acb0ad909d917a4630b Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Tue, 7 Mar 2023 10:30:21 -0600 Subject: [PATCH] added: variant of string.concat for appending single characters --- core/math/math.onyx | 2 +- core/string/string.onyx | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) 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 {} -- 2.25.1