From 937f8ce8e0ad13f2a8d19face3c3c65b1f081c71 Mon Sep 17 00:00:00 2001 From: scarf Date: Thu, 6 Oct 2022 11:58:20 +0900 Subject: [PATCH] refactor: make fuel_count const --- src/vehicle_use.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/vehicle_use.cpp b/src/vehicle_use.cpp index f755f78a16d4..d4bf234cbf85 100644 --- a/src/vehicle_use.cpp +++ b/src/vehicle_use.cpp @@ -373,10 +373,10 @@ void vehicle::control_engines() int e_toggle = 0; bool dirty = false; //count active engines - int fuel_count = 0; - for( int e : engines ) { - fuel_count += part_info( e ).engine_fuel_opts().size(); - } + const int fuel_count = std::accumulate( engines.begin(), engines.end(), int{0}, + [&]( int acc, int e ) { + return acc + part_info( e ).engine_fuel_opts().size(); + } ); const auto adjust_engine = [this]( int e_toggle ) { int i = 0;