Atila Neves: "C IS NOT MAGICALLY FAST, PART 2"

Atila Neves via Digitalmars-d digitalmars-d at puremagic.com
Tue Jul 19 09:13:21 PDT 2016


On Tuesday, 19 July 2016 at 16:01:01 UTC, Lodovico Giaretta wrote:
> On Tuesday, 19 July 2016 at 15:48:26 UTC, Atila Neves wrote:
>> Small string optimization should _help_ std::string, no?
>>
>> Atila
>
> Small string optimization will make the struct bigger, thus 
> making swapping slower. If the struct is no bigger than 2 
> pointers, swapping it is ultra fast.

Interesting. Read up on it and tried changing the strings to be 
~50 chars long. C++/std::string gets better, but C++/const char* 
still beats D by a small margin:

C: 1.852s
C++/std::string: 1.489s
C++/const char*: 1.034s
D: 1.188s

Could be the cost of swapping the "fat" in "fat pointer", in 
which case: worth it.

Atila


More information about the Digitalmars-d mailing list