@@ -1393,12 +1393,13 @@ fold_tuple_on_constants(PyObject *const_cache,
13931393 return SUCCESS ;
13941394}
13951395
1396+ #define MIN_CONST_SEQUENCE_SIZE 3
13961397/* Replace LOAD_CONST c1, LOAD_CONST c2 ... LOAD_CONST cN, BUILD_LIST N
13971398 with BUILD_LIST 0, LOAD_CONST (c1, c2, ... cN), LIST_EXTEND 1,
13981399 or BUILD_SET & SET_UPDATE respectively.
13991400*/
14001401static int
1401- optimize_const_sequence (PyObject * const_cache , cfg_instr * inst , int n , PyObject * consts )
1402+ optimize_build_list_or_set_with_constants (PyObject * const_cache , cfg_instr * inst , int n , PyObject * consts )
14021403{
14031404 assert (PyDict_CheckExact (const_cache ));
14041405 assert (PyList_CheckExact (consts ));
@@ -1408,7 +1409,7 @@ optimize_const_sequence(PyObject *const_cache, cfg_instr* inst, int n, PyObject
14081409 assert (build == BUILD_LIST || build == BUILD_SET );
14091410 int extend = build == BUILD_LIST ? LIST_EXTEND : SET_UPDATE ;
14101411
1411- if (n < 3 || !is_sequence_constant (inst , n )) {
1412+ if (n < MIN_CONST_SEQUENCE_SIZE || !is_sequence_constant (inst , n )) {
14121413 return SUCCESS ;
14131414 }
14141415 PyObject * newconst = PyTuple_New (n );
@@ -1812,7 +1813,7 @@ optimize_basic_block(PyObject *const_cache, basicblock *bb, PyObject *consts)
18121813 case BUILD_LIST :
18131814 case BUILD_SET :
18141815 if (i >= oparg ) {
1815- if (optimize_const_sequence (const_cache , inst - oparg , oparg , consts ) < 0 ) {
1816+ if (optimize_build_list_or_set_with_constants (const_cache , inst - oparg , oparg , consts ) < 0 ) {
18161817 goto error ;
18171818 }
18181819 }
0 commit comments