Skip to content

Commit 0e70699

Browse files
authored
Use move semantics in inventory::add_item() (#55100)
1 parent 1c9a584 commit 0e70699

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/inventory.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ item &inventory::add_item( item newit, bool keep_invlet, bool assign_invlet, boo
301301
} else {
302302
newit.invlet = it_ref->invlet;
303303
}
304-
elem.push_back( newit );
304+
elem.emplace_back( std::move( newit ) );
305305
return elem.back();
306306
} else if( keep_invlet && assign_invlet && it_ref->invlet == newit.invlet ) {
307307
// 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
316316
}
317317
update_cache_with_item( newit );
318318

319-
std::list<item> newstack;
320-
newstack.push_back( newit );
321-
items.push_back( newstack );
319+
items.emplace_back( std::list<item> { std::move( newit ) } );
322320
return items.back().back();
323321
}
324322

0 commit comments

Comments
 (0)