Bill & David,
First, let me apologize for top-posting in a reply to a reply, I know it makes things confusing, but we use Lotus Notes and this is how it does it.
The elided portion uses the same constructs for control, I just thought nobody'd want to wade through all 18. Also, I am comparing golden delicious with red delicious in the testing. That is, I'm only comparing the presence/absence of the /o, the rest of the code's the same (no interpolated vars in the elision, either).
As regards the parens, should I not use them? I thought they were needed for the OR-ed possible values--was I mistaken in this?
Thanks!
Deane
| [EMAIL PROTECTED]
09/12/2005 17:31
|
To: [EMAIL PROTECTED], [EMAIL PROTECTED] cc: [email protected] Subject: Re: regexp /o in a sub |
In a message dated 9/12/2005 4:27:22 P.M. Eastern Standard Time, [EMAIL PROTECTED] writes:
> On 9/12/05, [EMAIL PROTECTED]
> <[EMAIL PROTECTED]> wrote:
>
> > [ i get a performance improvement from the /o switch ]
>
> I am surprised, as I had thought that /o only applied when there
> was a variable within the regexp. I guess I was wrong on that count.
>
> Have you tried C<study> on your switch variable? Does that help or
> hurt?
>
> In response to your question, I would leave the /o switch in -- what could
> the penalty be?
>
>
> --
> David L Nicol
david & deane --
i, too, was very surprised by deane's observation of a performance increase with the use of /o in regexes that had no interpolated variables. i was wondering if there might have been an interpolated variable in the elided code, or if he was perhaps comparing different forms of ``switch'' construct, e.g., the if ... elsif ... elsif ... else ... form with the for/do flavor.
the other possibility that occurred to me was that the use of /o somehow prompted the regex optimizer to recognize that the capturing parentheses were never used and so effectively to eliminate them. i would expect some sort of performance gain from this, although whether it would be measurable or not is another question.
i would not expect study to be useful here. it is touted as being useful when many different regexes are applied to a single, very long string, which is not what deane has (at least not in the example given). whenever i have experimented with study in the recommended circumstances, i have seen no benefit -- although no detriment, either.
btw -- the /o switch does not work at all whatsoever in activestate perl version 5.6.x; it is a null operation. this was fixed in version 5.8.
bill walters
_______________________________________________ ActivePerl mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
