Skip to content

Commit

Permalink
Various item performance optimizations.
Browse files Browse the repository at this point in the history
  • Loading branch information
akrieger committed Feb 3, 2022
1 parent 70e72b4 commit a402db7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12521,7 +12521,7 @@ bool item::is_soft() const
return false;
}

const std::map<material_id, int> mats = made_of();
const std::map<material_id, int> &mats = made_of();
return std::all_of( mats.begin(), mats.end(), []( const std::pair<material_id, int> &mid ) {
return mid.first->soft();
} );
Expand Down
9 changes: 2 additions & 7 deletions src/item_contents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -552,9 +552,6 @@ void item_contents::force_insert_item( const item &it, item_pocket::pocket_type
std::pair<item_location, item_pocket *> item_contents::best_pocket( const item &it,
item_location &parent, const item *avoid, const bool allow_sealed, const bool ignore_settings )
{
if( !can_contain( it ).success() ) {
return { item_location(), nullptr };
}
std::pair<item_location, item_pocket *> ret;
ret.second = nullptr;
for( item_pocket &pocket : contents ) {
Expand Down Expand Up @@ -1191,8 +1188,7 @@ std::list<item *> item_contents::all_items_top( const std::function<bool( item_p
for( item_pocket &pocket : contents ) {
if( filter( pocket ) ) {
std::list<item *> contained_items = pocket.all_items_top();
all_items_internal.insert( all_items_internal.end(), contained_items.begin(),
contained_items.end() );
all_items_internal.splice( all_items_internal.end(), std::move( contained_items ) );
}
}
return all_items_internal;
Expand All @@ -1219,8 +1215,7 @@ std::list<const item *> item_contents::all_items_top( const
for( const item_pocket &pocket : contents ) {
if( filter( pocket ) ) {
std::list<const item *> contained_items = pocket.all_items_top();
all_items_internal.insert( all_items_internal.end(), contained_items.begin(),
contained_items.end() );
all_items_internal.splice( all_items_internal.end(), std::move( contained_items ) );
}
}
return all_items_internal;
Expand Down

0 comments on commit a402db7

Please sign in to comment.