@@ -243,23 +243,13 @@ STATIC void compile_generic_tuple(compiler_t *comp, mp_parse_node_struct_t *pns)
243243 c_tuple (comp , MP_PARSE_NODE_NULL , pns );
244244}
245245
246- STATIC bool node_is_const_false (mp_parse_node_t pn ) {
247- return MP_PARSE_NODE_IS_TOKEN_KIND (pn , MP_TOKEN_KW_FALSE )
248- || (MP_PARSE_NODE_IS_SMALL_INT (pn ) && MP_PARSE_NODE_LEAF_SMALL_INT (pn ) == 0 );
249- }
250-
251- STATIC bool node_is_const_true (mp_parse_node_t pn ) {
252- return MP_PARSE_NODE_IS_TOKEN_KIND (pn , MP_TOKEN_KW_TRUE )
253- || (MP_PARSE_NODE_IS_SMALL_INT (pn ) && MP_PARSE_NODE_LEAF_SMALL_INT (pn ) != 0 );
254- }
255-
256246STATIC void c_if_cond (compiler_t * comp , mp_parse_node_t pn , bool jump_if , int label ) {
257- if (node_is_const_false (pn )) {
247+ if (mp_parse_node_is_const_false (pn )) {
258248 if (jump_if == false) {
259249 EMIT_ARG (jump , label );
260250 }
261251 return ;
262- } else if (node_is_const_true (pn )) {
252+ } else if (mp_parse_node_is_const_true (pn )) {
263253 if (jump_if == true) {
264254 EMIT_ARG (jump , label );
265255 }
@@ -1218,14 +1208,14 @@ STATIC void compile_if_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
12181208 uint l_end = comp_next_label (comp );
12191209
12201210 // optimisation: don't emit anything when "if False"
1221- if (!node_is_const_false (pns -> nodes [0 ])) {
1211+ if (!mp_parse_node_is_const_false (pns -> nodes [0 ])) {
12221212 uint l_fail = comp_next_label (comp );
12231213 c_if_cond (comp , pns -> nodes [0 ], false, l_fail ); // if condition
12241214
12251215 compile_node (comp , pns -> nodes [1 ]); // if block
12261216
12271217 // optimisation: skip everything else when "if True"
1228- if (node_is_const_true (pns -> nodes [0 ])) {
1218+ if (mp_parse_node_is_const_true (pns -> nodes [0 ])) {
12291219 goto done ;
12301220 }
12311221
@@ -1250,14 +1240,14 @@ STATIC void compile_if_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
12501240 mp_parse_node_struct_t * pns_elif = (mp_parse_node_struct_t * )pn_elif [i ];
12511241
12521242 // optimisation: don't emit anything when "if False"
1253- if (!node_is_const_false (pns_elif -> nodes [0 ])) {
1243+ if (!mp_parse_node_is_const_false (pns_elif -> nodes [0 ])) {
12541244 uint l_fail = comp_next_label (comp );
12551245 c_if_cond (comp , pns_elif -> nodes [0 ], false, l_fail ); // elif condition
12561246
12571247 compile_node (comp , pns_elif -> nodes [1 ]); // elif block
12581248
12591249 // optimisation: skip everything else when "elif True"
1260- if (node_is_const_true (pns_elif -> nodes [0 ])) {
1250+ if (mp_parse_node_is_const_true (pns_elif -> nodes [0 ])) {
12611251 goto done ;
12621252 }
12631253
@@ -1294,9 +1284,9 @@ STATIC void compile_if_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
12941284STATIC void compile_while_stmt (compiler_t * comp , mp_parse_node_struct_t * pns ) {
12951285 START_BREAK_CONTINUE_BLOCK
12961286
1297- if (!node_is_const_false (pns -> nodes [0 ])) { // optimisation: don't emit anything for "while False"
1287+ if (!mp_parse_node_is_const_false (pns -> nodes [0 ])) { // optimisation: don't emit anything for "while False"
12981288 uint top_label = comp_next_label (comp );
1299- if (!node_is_const_true (pns -> nodes [0 ])) { // optimisation: don't jump to cond for "while True"
1289+ if (!mp_parse_node_is_const_true (pns -> nodes [0 ])) { // optimisation: don't jump to cond for "while True"
13001290 EMIT_ARG (jump , continue_label );
13011291 }
13021292 EMIT_ARG (label_assign , top_label );
0 commit comments