From 0e706991b3e38d2164e77996736302d5b7eb02da Mon Sep 17 00:00:00 2001 From: Binrui Dong Date: Sat, 5 Feb 2022 05:59:45 +0800 Subject: [PATCH] Use move semantics in inventory::add_item() (#55100) --- src/inventory.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/inventory.cpp b/src/inventory.cpp index 6bfaf06145323..cc678a0a0bc64 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -301,7 +301,7 @@ item &inventory::add_item( item newit, bool keep_invlet, bool assign_invlet, boo } else { newit.invlet = it_ref->invlet; } - elem.push_back( newit ); + elem.emplace_back( std::move( newit ) ); return elem.back(); } else if( keep_invlet && assign_invlet && it_ref->invlet == newit.invlet ) { // If keep_invlet is true, we'll be forcing other items out of their current invlet. @@ -316,9 +316,7 @@ item &inventory::add_item( item newit, bool keep_invlet, bool assign_invlet, boo } update_cache_with_item( newit ); - std::list newstack; - newstack.push_back( newit ); - items.push_back( newstack ); + items.emplace_back( std::list { std::move( newit ) } ); return items.back().back(); }