Quellcode durchsuchen

Use `llvm::zip()` to iterate over `callee_function_params`, `thunk_function_params` and `callee_arg_ids` (#5940)

Boaz Brickner vor 8 Monaten
Ursprung
Commit
fd3eb136af
1 geänderte Dateien mit 7 neuen und 9 gelöschten Zeilen
  1. 7 9
      toolchain/check/cpp_thunk.cpp

+ 7 - 9
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<SemIR::InstId> 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<SemIR::AnyParam>(callee_function_params[i])
-            .type_id;
+        context.insts().GetAs<SemIR::AnyParam>(callee_param_inst_id).type_id;
     SemIR::TypeId thunk_param_type_id =
-        context.insts()
-            .GetAs<SemIR::AnyParam>(thunk_function_params[i])
-            .type_id;
+        context.insts().GetAs<SemIR::AnyParam>(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(