Re: string comparison



Jürgen Exner schreef:

> Perl has a perfectly fine eq operator for comparing strings. There is
> no need to launch the big and expensive RE gun

OK, but that argument vaporizes if the RE was or will be loaded for
other parts of the program anyway.

> and then jump through
> hoops to "make it work" (e.g. for RE special characters).

No need to jump through hoops:

if ($a =~ m/\A(apple
|banana
|orange
)
\z/x) {
(untested)


> Would be interesting to benchmark a simple eq in a loop versus the
> concatenated or'ed REs. My gut feeling is that the loop with eq will
> be much faster

Compiled simple regexes are also very fast. I'll try benchmark later.

--
Affijn, Ruud

"Gewoon is een tijger."

.



Relevant Pages

  • Re: Why is C# 450% slower than C++ on nested loops ??
    ... The posted benchmark was crucial to ... > compilers generate for the loop and get over with it. ... > additions in the outer loops, which the C# compiler doesn't. ... gotten around to implementing every possible optimization in every language, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Jump Take offs
    ... I am excited to hear about your progress on the loop. ... Ask your coach if you are making the mohawk curve too deeply before ... I do the flip from a 3-turn, and it's helped a lot to think of a fairly ... clobber the jump. ...
    (rec.sport.skating.ice.recreational)
  • Re: Loop non-jump
    ... Replying to my own post after last night's lesson in which coach didn't ... let me off the hook and we drilled the loop for a long time. ... to get the jump going. ... brain, and my arms, shoulders and head pay no attention either...so we ...
    (rec.sport.skating.ice.recreational)
  • Re: Eclipse bug?
    ... and so are the longer-term thinkers pushing for a universal Web logon ... not give a valid one at all, and still get replies and make replies to ... wants users to jump through extra hoops for *their* software. ...
    (comp.lang.java.programmer)
  • Re: Loop non-jump
    ... backspin and the loop immediately seems much more doable (compared to ... When you jump on earth, you're not trying to get all the way ... I hate to admit it - sorry ant! ... the secure RBO, the solid alignment, the deep springing off the leg, ...
    (rec.sport.skating.ice.recreational)