Prefer emplace_back; take argument by value.

We copy the QString, so it makes sense to accept it by value and _move_
it into the collection instead. This causes the caller to move any
rvalue QString into the function, and then the QString is never actually
copied at all.
This commit is contained in:
Colin Wallace
2018-03-10 16:08:21 -08:00
parent 876615e3a3
commit a9d097cad9
2 changed files with 3 additions and 3 deletions

View File

@@ -27,9 +27,9 @@
void ComboBoxModel::addItem( const QString& item, std::unique_ptr<PixmapLoader> loader )
void ComboBoxModel::addItem( QString item, std::unique_ptr<PixmapLoader> loader )
{
m_items.push_back( std::make_pair( item, std::move(loader) ) );
m_items.emplace_back( std::move(item), std::move(loader) );
setRange( 0, m_items.size() - 1 );
}