lua-users home
lua-l archive

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


On Tue, Aug 27, 2019 at 5:05 PM Viacheslav Usov <via.usov@gmail.com> wrote:
> On Tue, Aug 27, 2019 at 2:46 PM Scott Morgan <blumf@blueyonder.co.uk> wrote:
> > Is there a limit to how big those sets can be? In practice I'd be looking at a few dozen allowed chars.
> I would rather ask about the complexity/efficiency of this. I may be mistaken, but the manual seems silent about this.

And you'll be right to ask it. It seems to be interpreted by a compact
loop inside the lib, not the fastest, but should be adeuqate unless he
has a very demanding app ( hot loop, long strings, ... ). I wrote a
previous message thinking on other pattern engines I've used ( which
compile the pattern, i.e., I've used some which compile a class to
min-char, max-char, bit mask or similar stuff ), then I remembered lua
is simple, so I said "The Source Olarte, use The Source" and looked it
up. The relevant function should be fast, but a hot spot may benefit a
lot from some character class optimization ( like collapsing
abcdefghijk to a-k and similar stuff ), otherwise the runtime seems
proportional to len(class)*len(string).

Francisco Olarte.