Post about comparing C, C++ and D performance with a real world project

Steven Schveighoffer schveiguy at yahoo.com
Fri Dec 8 15:41:35 UTC 2017


On 12/7/17 6:07 PM, Iain Buclaw wrote:
> On 7 December 2017 at 23:39, Daniel Kozak <kozzi11 at gmail.com> wrote:
>> The other slowdown is caused by concatenation. Because std::string += is
>> more simillar to std.array.(Ref)Appender
>>
> 
> Correct.  The semantics of ~= mean that the memory is copied around to
> a new allocation every time (unless the array is marked
> assumeSafeAppend).
> 

Slightly incorrect. If an array is not marked with the append bit (or 
not even part of the GC), it is copied on the *first* append. However, 
it is copied to a new GC block that DOES have the bit set. Further 
appends are amortized.

-Steve


More information about the Digitalmars-d mailing list