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

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Tue Jul 19 09:06:10 PDT 2016


On 7/19/16 11:48 AM, Atila Neves wrote:
> On Tuesday, 19 July 2016 at 15:28:45 UTC, Johan Engelen wrote:
>> On Tuesday, 19 July 2016 at 10:07:11 UTC, Atila Neves wrote:
>>> [...]
>>
>> Very interested to hear why one is faster than the other.
>>
>>> [...]
>>
>> The strings seem a little short, e.g. "foo1234foo" if I understand
>> correctly.
>> Could there be a performance hit in C++ due to small-string
>> optimization ? (Don't know if it is done at all, nor what the
>> threshold is)
>
>
> Small string optimization should _help_ std::string, no?

You can use strncmp, or strcmp and ensure a null terminator is always 
there in your C++ version.

That will use std::string semantics for swapping, but strcmp for comparison.

-Steve



More information about the Digitalmars-d mailing list