Reduction of temporaries

Hi all,

Recently, one of my colleagues made the following change in our code:

- h += q.substr(0, q_max);
+ h.append (q, 0, q_max);

This eliminates the temporary std::string returned by substr.

std::string has a few operations (insert/append/replace) that accept a
substring of of the input. Is this something that would be worth
finding automatically? (e.g. a clang-tidy check)


This seems like it would be a reasonable clang-tidy check to me.