[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Pattern matching: good practices ?
- From: Ico <lua@...>
- Date: Fri, 25 Dec 2009 12:17:10 +0100
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 ?