Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Re: Did the inefficiency of /i get fixed?

by benrwebb (Scribe)
on May 19, 2004 at 14:54 UTC ( #354631=note: print w/replies, xml ) Need Help??

in reply to Did the inefficiency of /i get fixed?

While I am impressed with everyone's research into the relative performance between m/foo/i and m/[fF][oO][oO]/ , Isn't it most important to keep your code readable and maintainable? Unless you are experiencing a specific performance problem, I wouldn't worry too much over it. And if you ARE experiencing a performance problem, I would make sure that the comments were properly verbose:

# This was changed in the interest of performance, the # regex are equivilent in function # /new/i /[nN][eE][wW]/

I'm generally against sacrificing maintainablilty for performance without strong justification, but there are of course those who disagree (and in many situations, they're right)

Replies are listed 'Best First'.
Re: Re: Did the inefficiency of /i get fixed?
by itub (Priest) on May 19, 2004 at 15:06 UTC

    I agree that including comments is a good idea, but the performance difference I mentioned above is really important IMO for any large problem. I once had to apply some regexes a 1 GB UTF-8 file in a case-insensitive way, and that time jumping through hoops in the interest of performance really mattered.

      Exactly my point. If I'm just, oh for instance parsing a command line arg, or some interactive user input, I'm going for readability every time. If I'm in a situation where I'm doing a data transformation between two systems (say an OS390 to UNIX pipe, not that I've ever had to do that :-) ), I'll look at performance more closely (although I'll admit I still write it the quick, easy way first and then optimize after the fact).

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://354631]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (7)
As of 2020-01-23 16:41 GMT
Find Nodes?
    Voting Booth?