Skip to content

Commit 2ed6955

Browse files
committed
libscript: Spanify MCScriptBytecodeOp_Invoke::Execute()
1 parent 3e64615 commit 2ed6955

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

libscript/src/script-bytecode.hpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -276,15 +276,12 @@ struct MCScriptBytecodeOp_Invoke
276276
t_result_reg = ctxt.GetArgument(1);
277277

278278
// The argument list starts at the third argument.
279-
const uindex_t *t_argument_regs;
280-
uindex_t t_argument_count;
281-
t_argument_regs = ctxt.GetArgumentList() + 2;
282-
t_argument_count = ctxt.GetArgumentCount() - 2;
279+
MCSpan<const uindex_t> t_arguments(ctxt.GetArguments().subspan(2));
283280

284281
#ifdef DEBUG_EXECUTION
285282
MCLog("Select handler into register %u", t_result_reg);
286-
for(uindex_t i = 0; i < t_argument_count; i++)
287-
MCLog(" argument register %u", t_argument_regs[i]);
283+
for (MCSpan<const uindex_t> t_rest = t_arguments; !t_rest.empty(); ++t_rest)
284+
MCLog(" argument register %u", *t_rest);
288285
#endif
289286

290287
// If the definition kind is a group, then we must select which handler
@@ -296,7 +293,7 @@ struct MCScriptBytecodeOp_Invoke
296293
SelectDefinitionFromGroup(ctxt,
297294
t_instance,
298295
static_cast<MCScriptDefinitionGroupDefinition *>(t_definition),
299-
MCMakeSpan(t_argument_regs, t_argument_count),
296+
t_arguments,
300297
t_resolved_instance,
301298
t_resolved_definition);
302299
}
@@ -321,7 +318,7 @@ struct MCScriptBytecodeOp_Invoke
321318
ctxt.PushFrame(t_resolved_instance,
322319
static_cast<MCScriptHandlerDefinition *>(t_resolved_definition),
323320
t_result_reg,
324-
MCMakeSpan(t_argument_regs, t_argument_count));
321+
t_arguments);
325322
}
326323
break;
327324

@@ -330,7 +327,7 @@ struct MCScriptBytecodeOp_Invoke
330327
ctxt.InvokeForeign(t_resolved_instance,
331328
static_cast<MCScriptForeignHandlerDefinition *>(t_resolved_definition),
332329
t_result_reg,
333-
MCMakeSpan(t_argument_regs, t_argument_count));
330+
t_arguments);
334331
}
335332
break;
336333

0 commit comments

Comments
 (0)