On Wednesday, 12 January 2022 at 19:55:41 UTC, Moth wrote:
[snip]
Another issue is the way concatenation is implemented. Since
FixedStrings have compile-time size, this potentially means
every time you concatenate a string in your code you get
another instantiation of FixedString. This can lead to a LOT
of template bloat if you're not careful, which may quickly
outweigh any benefits you may have gained from not using the
built-in strings.
oh dear, that doesn't sound good. i hadn't considered that at
all. i'm not sure how to even begin going about fixing that...
One thing you could potentially do is to round the size of the
result up to, say, a power of two. That way, instead of
instantiating a new template for every individual string length,
you only instantiate `FixedString!16`, `FixedString!32`,
`FixedString!64`, etc.
Of course, doing this will leave you with some wasted memory at
runtime. So you will probably want to run some benchmarks to
compare performance before and after.