lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> One question, would your solution of:
>
>   line = lpeg.P" says hello"
>   p = (1 - line)^0 * line
>
> be more efficient if written as:
>
>   line = lpeg.P" says hello"
>   p = (1 - #line)^0 * line
>
> I have added a "#" to "line" so as to consume no input, on the basis that 
> "consuming input" might take more work than not doing so. Or is that 
> irrelevant?

Actually, consuming no input is slightly less efficient, because the
machine must consume the input (otherwise how to match it?) and then
backtrack. But in this particular case we have '-line', so it does
not consume input anyway.
 
-- Roberto