]> sigrok.org Git - pulseview.git/commit
Use emplace_back() where possible.
authorUwe Hermann <redacted>
Fri, 10 Mar 2017 20:32:43 +0000 (21:32 +0100)
committerUwe Hermann <redacted>
Sat, 11 Mar 2017 12:06:03 +0000 (13:06 +0100)
commit326cf6feb8598aa03a35fd6f678e4f536f168149
tree1c721950ad673bc76265b5fc16ff6a8b868b381b
parent1f1d55ce48ae1dac0f077c60827a41b368b5207a
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.
pv/data/decoderstack.cpp
pv/data/logicsegment.cpp
pv/session.cpp