Skip to content

Commit

Permalink
filter: use the O(log(n)) instead of O(n) method
Browse files Browse the repository at this point in the history
  • Loading branch information
Brambor committed Dec 14, 2024
1 parent a7c5b6f commit ecb2bbd
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" ) ) ) ) );

Check failure on line 38 in src/item_search.cpp

View workflow job for this annotation

GitHub Actions / build (src)

Redundant parentheses. [cata-redundant-parentheses,-warnings-as-errors]
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_type( STATIC(

Check failure on line 212 in src/recipe_dictionary.cpp

View workflow job for this annotation

GitHub Actions / build (src)

Redundant parentheses. [cata-redundant-parentheses,-warnings-as-errors]

Check failure on line 212 in src/recipe_dictionary.cpp

View workflow job for this annotation

GitHub Actions / build (src)

no member named 'find_type' in 'Item_factory' [clang-diagnostic-error]
itype_id( "debug_item_search" ) ) ) ) );
return uni;
}

Expand Down

0 comments on commit ecb2bbd

Please sign in to comment.