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

Re: [MacPerl] Know tell me that this is a bug???



At 08.24 9/29/97, Michael and MJ Houghton wrote:
>Matthias opined:
>[snip]
>>
>> Your technique looks ok, but I would think that glueing all regexps together
>> into a single regexp, i.e. "m!xyzzy|abc!o" instead of "m!xyzzy!o || m!abc!o"
>> has the potential to be faster.
>>
>The Camel book suggests that using the simple regexps with the short-circuit
>operators tends to come out ahead. With a simple regexp, it can use
>Boyer-Moore instead of setting up the NFA. I think I saw this in the
>efficiency chapter.

There are two issues at hand.  For a given regex, it is faster to avoid
alternation and group several regexes together (the latter version would be
faster).  However, when o is used, at some certain number of uses of the
regex, the grouped version would become faster (the former version would be
faster).  For those who don't know, the trailing o tells Perl to only
compile the regex once, so eventually the optimization provided by o would
counteract the slowdown the alternation causes.

--
Chris Nandor             pudge@pobox.com             http://pudge.net/
%PGPKey=('B76E72AD',[1024,'0824 090B CE73 CA10  1FF7 7F13 8180 B6B6'])



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch