Skip to content

Commit e514109

Browse files
authored
Various item performance optimizations. (#55070)
1 parent c6e58fc commit e514109

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

src/item.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12521,7 +12521,7 @@ bool item::is_soft() const
1252112521
return false;
1252212522
}
1252312523

12524-
const std::map<material_id, int> mats = made_of();
12524+
const std::map<material_id, int> &mats = made_of();
1252512525
return std::all_of( mats.begin(), mats.end(), []( const std::pair<material_id, int> &mid ) {
1252612526
return mid.first->soft();
1252712527
} );

src/item_contents.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -552,9 +552,6 @@ void item_contents::force_insert_item( const item &it, item_pocket::pocket_type
552552
std::pair<item_location, item_pocket *> item_contents::best_pocket( const item &it,
553553
item_location &parent, const item *avoid, const bool allow_sealed, const bool ignore_settings )
554554
{
555-
if( !can_contain( it ).success() ) {
556-
return { item_location(), nullptr };
557-
}
558555
std::pair<item_location, item_pocket *> ret;
559556
ret.second = nullptr;
560557
for( item_pocket &pocket : contents ) {
@@ -1191,8 +1188,7 @@ std::list<item *> item_contents::all_items_top( const std::function<bool( item_p
11911188
for( item_pocket &pocket : contents ) {
11921189
if( filter( pocket ) ) {
11931190
std::list<item *> contained_items = pocket.all_items_top();
1194-
all_items_internal.insert( all_items_internal.end(), contained_items.begin(),
1195-
contained_items.end() );
1191+
all_items_internal.splice( all_items_internal.end(), std::move( contained_items ) );
11961192
}
11971193
}
11981194
return all_items_internal;
@@ -1219,8 +1215,7 @@ std::list<const item *> item_contents::all_items_top( const
12191215
for( const item_pocket &pocket : contents ) {
12201216
if( filter( pocket ) ) {
12211217
std::list<const item *> contained_items = pocket.all_items_top();
1222-
all_items_internal.insert( all_items_internal.end(), contained_items.begin(),
1223-
contained_items.end() );
1218+
all_items_internal.splice( all_items_internal.end(), std::move( contained_items ) );
12241219
}
12251220
}
12261221
return all_items_internal;

0 commit comments

Comments
 (0)