Skip to content

Commit

Permalink
Merge pull request CleverRaven#78569 from Brambor/filter-log-n
Browse files Browse the repository at this point in the history
filter: use the O(log(n)) instead of O(n) method
  • Loading branch information
Maleclypse authored Dec 15, 2024
2 parents e166bbc + 5ae50e5 commit 7acb286
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
6 changes: 2 additions & 4 deletions src/item_search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,8 @@ static std::function< bool( const item & )> can_contain_filter( std::string_view
}
// copy the debug item template (itype), put it on heap so the itype pointer doesn't move
// TODO unique_ptr
std::shared_ptr<itype> filtered_fake_itype = std::make_shared<itype>( *( item_controller->find( [](
const itype & i ) {
return i.get_id() == STATIC( itype_id( "debug_item_search" ) );
} )[0] ) );
std::shared_ptr<itype> filtered_fake_itype = std::make_shared<itype>
( *item_controller->find_template( STATIC( itype_id( "debug_item_search" ) ) ) );
item filtered_fake_item = set_function( filtered_fake_itype.get(), uni );
// pass to keep filtered_fake_itype valid until lambda capture is destroyed (while item is needed)
return [filtered_fake_itype, filtered_fake_item]( const item & i ) {
Expand Down
5 changes: 2 additions & 3 deletions src/recipe_dictionary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,8 @@ static Unit can_contain_filter( std::string_view hint, std::string_view txt, Uni
popup( err.what() );
}
// copy the debug item template (itype)
filtered_fake_itype = itype( *( item_controller->find( []( const itype & i ) {
return i.get_id() == STATIC( itype_id( "debug_item_search" ) );
} )[0] ) );
filtered_fake_itype = itype( *item_controller->find_template( STATIC(
itype_id( "debug_item_search" ) ) ) );
return uni;
}

Expand Down

0 comments on commit 7acb286

Please sign in to comment.