diff options
| author | Josh Klar <josh@klar.sh> | 2019-09-26 16:48:02 -0700 |
|---|---|---|
| committer | Jeff Epler <jepler@gmail.com> | 2020-03-09 08:16:07 -0500 |
| commit | 40bc05ee1eafcc2f0b3ed48f212a1526b65163bc (patch) | |
| tree | 3f665fe7441eec92bbedd3f2e3162446397636e4 /py/lexer.c | |
| parent | 3a7a5ba6860c787cc691b5c828eff9a130f39526 (diff) | |
Address dpgeorge feedback - largely simplifications
Diffstat (limited to 'py/lexer.c')
| -rw-r--r-- | py/lexer.c | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/py/lexer.c b/py/lexer.c index 6894ada47..c3f4e6506 100644 --- a/py/lexer.c +++ b/py/lexer.c @@ -129,29 +129,21 @@ STATIC bool is_tail_of_identifier(mp_lexer_t *lex) { STATIC void swap_char_banks(mp_lexer_t *lex) { if (lex->vstr_postfix_processing) { - unichar h0, h1, h2; - - h0 = lex->chr0; - h1 = lex->chr1; - h2 = lex->chr2; - - lex->chr0 = lex->vstr_postfix.len > 0 ? lex->vstr_postfix.buf[0] : 0; - lex->chr1 = lex->vstr_postfix.len > 1 ? lex->vstr_postfix.buf[1] : 0; - lex->chr2 = lex->vstr_postfix.len > 2 ? lex->vstr_postfix.buf[2] : 0; - lex->chr3 = h0; - lex->chr4 = h1; - lex->chr5 = h2; - - lex->vstr_postfix_idx = lex->vstr_postfix.len > 2 ? 3 : lex->vstr_postfix.len; + lex->chr3 = lex->chr0; + lex->chr4 = lex->chr1; + lex->chr5 = lex->chr2; + lex->chr0 = lex->vstr_postfix.buf[0]; + lex->chr1 = lex->vstr_postfix.buf[1]; + lex->chr2 = lex->vstr_postfix.buf[2]; + + lex->vstr_postfix_idx = 3; } else { // blindly reset to the "backup" bank when done postfix processing // this restores control to the mp_reader lex->chr0 = lex->chr3; lex->chr1 = lex->chr4; lex->chr2 = lex->chr5; - lex->chr3 = 0; - lex->chr4 = 0; - lex->chr5 = 0; + // willfully ignoring setting chr3-5 here - WARNING consider those garbage data now vstr_reset(&lex->vstr_postfix); lex->vstr_postfix_idx = 0; |
