diff options
author | Damien George <damien.p.george@gmail.com> | 2015-01-14 21:32:42 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2015-01-14 21:32:42 +0000 |
commit | d2d64f00fb7f1487c1fa21a456e003a801d7e711 (patch) | |
tree | 7345a9ba92baed508c4287bfca5ab09d67290821 /py/parse.c | |
parent | 65ef6b768cbba6a55f28c13433c3763c6567045e (diff) | |
download | micropython-d2d64f00fb7f1487c1fa21a456e003a801d7e711.tar.gz micropython-d2d64f00fb7f1487c1fa21a456e003a801d7e711.zip |
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.
Diffstat (limited to 'py/parse.c')
-rw-r--r-- | py/parse.c | 8 |
1 files changed, 7 insertions, 1 deletions
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 } } } |