[3.14] GH-128161: Remove redundant GET_ITER from list comprehension code (GH-134778)

This commit is contained in:
Mark Shannon 2025-05-27 12:29:48 +01:00 committed by GitHub
parent 266b541cc6
commit 00122c8b2a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 51 additions and 17 deletions

View file

@ -4543,9 +4543,9 @@ codegen_async_comprehension_generator(compiler *c, location loc,
else {
/* Sub-iter - calculate on the fly */
VISIT(c, expr, gen->iter);
ADDOP(c, LOC(gen->iter), GET_AITER);
}
}
ADDOP(c, LOC(gen->iter), GET_AITER);
USE_LABEL(c, start);
/* Runtime will push a block here, so we need to account for that */
@ -4757,19 +4757,6 @@ pop_inlined_comprehension_state(compiler *c, location loc,
return SUCCESS;
}
static inline int
codegen_comprehension_iter(compiler *c, comprehension_ty comp)
{
VISIT(c, expr, comp->iter);
if (comp->is_async) {
ADDOP(c, LOC(comp->iter), GET_AITER);
}
else {
ADDOP(c, LOC(comp->iter), GET_ITER);
}
return SUCCESS;
}
static int
codegen_comprehension(compiler *c, expr_ty e, int type,
identifier name, asdl_comprehension_seq *generators, expr_ty elt,
@ -4789,9 +4776,7 @@ codegen_comprehension(compiler *c, expr_ty e, int type,
outermost = (comprehension_ty) asdl_seq_GET(generators, 0);
if (is_inlined) {
if (codegen_comprehension_iter(c, outermost)) {
goto error;
}
VISIT(c, expr, outermost->iter);
if (push_inlined_comprehension_state(c, loc, entry, &inline_state)) {
goto error;
}