Obviously, it does; instead of allocating a new string for every token, you can just save the start &amp; end index of a token, and actually allocate a new string only in the case where the parser actually requests&#x2F;uses that token in the AST.