@@ -1397,25 +1397,15 @@ fold_tuple_on_constants(PyObject *const_cache,
13971397// with BUILD_LIST 0, LOAD_CONST (x, y, z), LIST_EXTEND 1
13981398// or BUILD_SET & SET_UPDATE respectively.
13991399static int
1400- optimize_const_sequence (PyObject * const_cache ,
1401- cfg_instr * inst ,
1402- int n , PyObject * consts )
1400+ optimize_const_sequence (PyObject * const_cache , cfg_instr * inst , int n , PyObject * consts )
14031401{
14041402 assert (PyDict_CheckExact (const_cache ));
14051403 assert (PyList_CheckExact (consts ));
14061404 assert (inst [n ].i_oparg == n );
14071405
1408- int construct_list = inst [n ].i_opcode == BUILD_LIST ;
1409- int build , extend ;
1410- if (!construct_list ) {
1411- assert (inst [n ].i_opcode == BUILD_SET );
1412- build = BUILD_SET ;
1413- extend = SET_UPDATE ;
1414- }
1415- else {
1416- build = BUILD_LIST ;
1417- extend = LIST_EXTEND ;
1418- }
1406+ int build = inst [n ].i_opcode ;
1407+ assert (build == BUILD_LIST || build == BUILD_SET );
1408+ int extend = (build == BUILD_LIST ) ? SET_UPDATE : LIST_EXTEND
14191409
14201410 if (n < 3 || !is_sequence_constant (inst , n )) {
14211411 return SUCCESS ;
@@ -1433,17 +1423,15 @@ optimize_const_sequence(PyObject *const_cache,
14331423 }
14341424 PyTuple_SET_ITEM (newconst , i , constant );
14351425 }
1436- if (! construct_list ) {
1426+ if (build == BUILD_SET ) {
14371427 PyObject * frozenset = PyFrozenSet_New (newconst );
14381428 if (frozenset == NULL ) {
14391429 return ERROR ;
14401430 }
14411431 Py_SETREF (newconst , frozenset );
14421432 }
14431433 int index = add_const (newconst , consts , const_cache );
1444- if (index < 0 ) {
1445- return ERROR ;
1446- }
1434+ RETURN_IF_ERROR (index );
14471435 INSTR_SET_OP1 (& inst [0 ], build , 0 );
14481436 for (int i = 1 ; i < n - 1 ; i ++ ) {
14491437 INSTR_SET_OP0 (& inst [i ], NOP );
0 commit comments