lua-users home
lua-l archive

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


Hi all,

Recently I've been bitten a few times by very bad performing patterns
using string.match(), which in some cases took several seconds to run on
an input string of several tens of kilobytes.

Usually I 'fix' this with some trial and error and speed tests, changing
non-greedy captures into greedy ones, which is pretty much sufficient
most of the time.

Still, I was wondering if anybody has ever written a sort of 'best
practices' document for writing lua patterns, describing the impact of
various constructs on performance, and giving tips on writing good
performing patterns, speed- and memorywise.

I found the 'Patterns Tutorial' in the wiki, but this talks mainly about
how to write patterns, but not about what options to choose when there
are multiple options to create a pattern.

Any 'generally applicable' good tips to start with ?

Thanks,

Ico

-- 
:wq
^X^Cy^K^X^C^C^C^C