Skip to content
  • 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