I was wondering what the best options for putting characters together to make Text in a performant way. It looks like the only way I see right now is to manually convert each character to text, then concat them together one by one. Is this reasonable for high performance scenarios? What are the options?
Looking at the base library implementation it seems thats what fromIter
does anyways.
/// Creates a `Text` value from a `Char` iterator.
///
/// ```motoko include=import
/// let text = Text.fromIter(['a', 'b', 'c'].vals()); // "abc"
/// ```
public func fromIter(cs : Iter.Iter<Char>) : Text {
var r = "";
for (c in cs) {
r #= Prim.charToText(c)
};
return r
};
It just seems like thats a lot of Text being created