Skip to content

Commit

Permalink
docs: write todo to use ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
scarf005 committed Mar 30, 2023
1 parent cd7c2f2 commit 48a5fc2
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/activity_item_handling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3196,6 +3196,18 @@ bool find_auto_consume( player &p, const bool food )
if( index < 0 ) {
continue;
}
/**
* TODO: when we get to use ranges library, cursor should be replaced with:
*
* const auto shortest = vehitems | filter_view(ok_to_consume) | max_element(spoilage_sort_order)
*
* rationale:
* 1. much more readable (mandatory FP shilling)
* 2. filter_view does not create a new container (it's a view), so it's performant
*
* @see https://en.cppreference.com/w/cpp/ranges/filter_view
* @see https://en.cppreference.com/w/cpp/algorithm/ranges/max_element
*/
vehicle_stack vehitems = veh.get_items( index );
for( item &it : vehitems ) {
if( should_skip( it ) ) {
Expand Down

0 comments on commit 48a5fc2

Please sign in to comment.