From: Uwe Hermann Date: Fri, 10 Mar 2017 20:32:43 +0000 (+0100) Subject: Use emplace_back() where possible. X-Git-Tag: pulseview-0.4.0~159 X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=commitdiff_plain;h=326cf6feb8598aa03a35fd6f678e4f536f168149;hp=326cf6feb8598aa03a35fd6f678e4f536f168149 Use emplace_back() where possible. This patch was generated using clang-tidy: clang-tidy -checks="-*,modernize-use-emplace" -fix Using emplace_back() has multiple advantages: - It's usually shorter and easier to read. - It's more efficient. V1: v.push_back("foo"); V2: v.emplace_back("foo"); V1 will construct a temporary std::string from the string literal "foo", another copy of that temporary object will be constructed and placed into the vector 'v', then the temporary object's destructor will be called. V2 will simply create a std::string directly in the vector 'v', i.e. there's only one construction (not 2) and no destructor needs to be called. ---