Fully transitive const is not necessary
Walter Bright
newshound1 at digitalmars.com
Sun Apr 27 15:05:14 PDT 2008
Sascha Katzner wrote:
> Correct me if I'm wrong, but if you want to concatenate two invariant
> strings, you have to allocate a new buffer. Isn't that a possible speed
> penalty compared to regular strings? Since if you use regular strings
> you can allocate one of the two string buffers beforehand big enough and
> save this allocation, with invariant strings you don't have this option.
>
> ...or to rephrase my question, wouldn't a StringBuilder Class without
> invariant strings be much faster?
D doesn't *prevent* you from building a string using a mutable character
array. The cases where it is faster to do so, however, tend to be
modularizable. When the function is done, the result can be cast to an
invariant string.
More information about the Digitalmars-d
mailing list