Skip to content

Commit 00818c8

Browse files
fix _BINARY_OP_SUBSCR_DICT optimization
1 parent cf59bf7 commit 00818c8

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

Python/optimizer_bytecodes.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -515,18 +515,18 @@ dummy_func(void) {
515515
}
516516

517517
op(_BINARY_OP_SUBSCR_DICT, (dict_st, sub_st -- res, ds, ss)) {
518-
PyObject *sub = sym_get_const(ctx, sub_st);
519-
if (sub != NULL) {
520-
optimize_dict_known_hash(ctx, dependencies, this_instr,
521-
sub, _BINARY_OP_SUBSCR_DICT_KNOWN_HASH);
522-
}
523518
res = sym_new_not_null(ctx);
524519
ds = dict_st;
525520
ss = sub_st;
521+
PyObject *sub = sym_get_const(ctx, sub_st);
526522
if (sym_is_not_container(sub_st) &&
527523
sym_matches_type(dict_st, &PyFrozenDict_Type)) {
528524
REPLACE_OPCODE_IF_EVALUATES_PURE(dict_st, sub_st, res);
529525
}
526+
else if (sub != NULL) {
527+
optimize_dict_known_hash(ctx, dependencies, this_instr,
528+
sub, _BINARY_OP_SUBSCR_DICT_KNOWN_HASH);
529+
}
530530
}
531531

532532
op(_BINARY_OP_SUBSCR_LIST_SLICE, (list_st, sub_st -- res, ls, ss)) {

Python/optimizer_cases.c.h

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)