From fd3eb136af5870980088dcaa16339811f6b13814 Mon Sep 17 00:00:00 2001 From: Boaz Brickner Date: Mon, 11 Aug 2025 16:57:42 +0200 Subject: [PATCH] Use `llvm::zip()` to iterate over `callee_function_params`, `thunk_function_params` and `callee_arg_ids` (#5940) --- toolchain/check/cpp_thunk.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/toolchain/check/cpp_thunk.cpp b/toolchain/check/cpp_thunk.cpp index fbc94b154133..70b0497fe884 100644 --- a/toolchain/check/cpp_thunk.cpp +++ b/toolchain/check/cpp_thunk.cpp @@ -328,18 +328,16 @@ auto PerformCppThunkCall(Context& context, SemIR::LocId loc_id, CARBON_CHECK(thunk_function_params.size() == num_params); CARBON_CHECK(callee_arg_ids.size() == num_params); llvm::SmallVector thunk_arg_ids; - thunk_arg_ids.reserve(callee_arg_ids.size()); - for (size_t i = 0; i < callee_function_params.size(); ++i) { + thunk_arg_ids.reserve(num_params); + for (auto [callee_param_inst_id, thunk_param_inst_id, callee_arg_id] : + llvm::zip(callee_function_params, thunk_function_params, + callee_arg_ids)) { SemIR::TypeId callee_param_type_id = - context.insts() - .GetAs(callee_function_params[i]) - .type_id; + context.insts().GetAs(callee_param_inst_id).type_id; SemIR::TypeId thunk_param_type_id = - context.insts() - .GetAs(thunk_function_params[i]) - .type_id; + context.insts().GetAs(thunk_param_inst_id).type_id; - SemIR::InstId arg_id = callee_arg_ids[i]; + SemIR::InstId arg_id = callee_arg_id; if (callee_param_type_id != thunk_param_type_id) { CARBON_CHECK(thunk_param_type_id == GetPointerType(context, context.types().GetInstId(