go ahead... be a heretic | |
PerlMonks |
Re: simple string comparison for efficiencyby GrandFather (Saint) |
on May 28, 2009 at 21:05 UTC ( [id://766750]=note: print w/replies, xml ) | Need Help?? |
Tell us about the larger picture. There is likely to be room for improving whatever you are doing at present, or at least for us to target solutions to whatever the bigger problem is. Most gains in performance are not obtained by micro-optimizations such as you are asking for. Some tricks that will give huge performance gains in some situations will cripple the code in other situations. That said, you can build masks then xor the strings to give something like the fast match you are looking for where the strings to be matched are fairly long. Consider:
Prints:
If you can cache the masks (say you were matching all strings against all others for example) then you get a greater gain. True laziness is hard work
In Section
Seekers of Perl Wisdom
|
|