[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: patch: C-style string lexing
- From: "Eric Tetz" <erictetz@...>
- Date: Thu, 31 Jan 2008 12:50:31 -0800
> My point was mostly that if the performance is a concern, then the place to
> fix this is not by changing the lexer but to introduce constant folding into
> the compiler for this operation.
I think Roberto's point is that constant folding wouldn't save you anything in
the common case (where the concatenation is not in a loop). The compiler would
still generate N-2 intermediate strings, it would just do it during code
generation rather than execution (both happen at runtime in Lua).
If it could be done while lexing, it would be *far* more efficient. It's no
more expensive to lex fifty 10-character strings than one 500-character string
(you're just skipping unwanted characters); the parser/code generator sees only
1 string, no concatenation required, no intermediates allocated.