mercredi 3 juin 2015

small string optimization(SSO) and move semantics

std::string test = "small_string";

std::string test2_1 = test;   // line 1

std::string test2_2 = std::move(test); // line 2

hi, i am curious about which version of string create is fast. test2_1 or test2_2?

I was looking into the implement on VC++ version of std::string, found out that test2_1 version will call memcpy(_First1, _First2, _Count)) and test2_2 will call memmove(_First1, _First2, _Count)), and I just wonder which one is better if I want my code run faster.

Aucun commentaire:

Enregistrer un commentaire