[cfe-dev] Reduction of temporaries

Richard Smith via cfe-dev cfe-dev at lists.llvm.org
Mon Apr 15 14:27:59 PDT 2019


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

On Fri, 12 Apr 2019 at 01:56, Csaba Raduly via cfe-dev
<cfe-dev at lists.llvm.org> wrote:
>
> 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)
>
> Csaba
> --
> You can get very substantial performance improvements
> by not doing the right thing. - Scott Meyers, An Effective C++11/14 Sampler
> So if you're looking for a completely portable, 100% standards-conformat way
> to get the wrong information: this is what you want. - Scott Meyers (C++TDaWYK)
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev


More information about the cfe-dev mailing list