1. 17 Feb, 2017 3 commits
    • Damien George's avatar
      py: Do adjacent str/bytes literal concatenation in lexer, not compiler. · 534b7c36
      Damien George authored
      It's much more efficient in RAM and code size to do implicit literal string
      concatenation in the lexer, as opposed to the compiler.
      
      RAM usage is reduced because the concatenation can be done right away in the
      tokeniser by just accumulating the string/bytes literals into the lexer's
      vstr.  Prior to this patch adjacent strings/bytes would create a parse tree
      (one node per string/bytes) and then in the compiler a whole new chunk of
      memory was allocated to store the concatenated string, which used more than
      double the memory compared to just accumulating in the lexer.
      
      This patch also significantly reduces code size:
      
      bare-arm: -204
      minimal:  -204
      unix x64: -328
      stmhal:   -208
      esp8266:  -284
      cc3200:   -224
      534b7c36
    • Damien George's avatar
      py/lexer: Simplify handling of line-continuation error. · 773278ec
      Damien George authored
      Previous to this patch there was an explicit check for errors with line
      continuation (where backslash was not immediately followed by a newline).
      
      But this check is not necessary: if there is an error then the remaining
      logic of the tokeniser will reject the backslash and correctly produce a
      syntax error.
      773278ec
    • Damien George's avatar
      py/lexer: Use strcmp to make keyword searching more efficient. · ae436797
      Damien George authored
      Since the table of keywords is sorted, we can use strcmp to do the search
      and stop part way through the search if the comparison is less-than.
      
      Because all tokens that are names are subject to this search, this
      optimisation will improve the overall speed of the lexer when processing
      a script.
      
      The change also decreases code size by a little bit because we now use
      strcmp instead of the custom str_strn_equal function.
      ae436797
  2. 16 Feb, 2017 37 commits