From d2d64f00fb7f1487c1fa21a456e003a801d7e711 Mon Sep 17 00:00:00 2001 From: Damien George Date: Wed, 14 Jan 2015 21:32:42 +0000 Subject: py: Add "default" to switches to allow better code flow analysis. This helps compiler produce smaller code. Saves 124 bytes on stmhal and bare-arm. --- py/parse.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'py/parse.c') diff --git a/py/parse.c b/py/parse.c index 6d2108dcaa..c60bbb17e5 100644 --- a/py/parse.c +++ b/py/parse.c @@ -456,11 +456,13 @@ mp_parse_node_t mp_parse(mp_lexer_t *lex, mp_parse_input_kind_t input_kind, mp_p } break; case RULE_ARG_RULE: + rule_or_no_other_choice: push_rule(&parser, rule_src_line, rule, i + 1); // save this or-rule push_rule_from_arg(&parser, rule->arg[i]); // push child of or-rule goto next_rule; default: assert(0); + goto rule_or_no_other_choice; // to help flow control analysis } } if ((rule->arg[i] & RULE_ARG_KIND_MASK) == RULE_ARG_TOK) { @@ -520,14 +522,16 @@ mp_parse_node_t mp_parse(mp_lexer_t *lex, mp_parse_input_kind_t input_kind, mp_p } } break; - } + } case RULE_ARG_RULE: case RULE_ARG_OPT_RULE: + rule_and_no_other_choice: push_rule(&parser, rule_src_line, rule, i + 1); // save this and-rule push_rule_from_arg(&parser, rule->arg[i]); // push child of and-rule goto next_rule; default: assert(0); + goto rule_and_no_other_choice; // to help flow control analysis } } @@ -674,11 +678,13 @@ mp_parse_node_t mp_parse(mp_lexer_t *lex, mp_parse_input_kind_t input_kind, mp_p } break; case RULE_ARG_RULE: + rule_list_no_other_choice: push_rule(&parser, rule_src_line, rule, i + 1); // save this list-rule push_rule_from_arg(&parser, arg); // push child of list-rule goto next_rule; default: assert(0); + goto rule_list_no_other_choice; // to help flow control analysis } } } -- cgit v1.2.3