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

Re: Speeding up sort routines

by bwana147 (Pilgrim)
on Jul 02, 2001 at 20:02 UTC ( [id://93219]=note: print w/replies, xml ) Need Help??


in reply to Speeding up sort routines

First off, as davorg puts it, you might consider caching to speed up the process. Then, since you seem to be sure you $a->{ip} is really an IP address, you might want to avoid the cost of firing the regexp engine.

I don't know if this would be a lot quicker, but you can easily turn an IP into a 32-bits integer using and eval and the v notation, which would allow you to compare two integers instead of four times two:

my $a32 = eval "v$a->{ip}"; my $b32 = eval "v$b->{ip}"; $a32 <=> $b32 || ...

--bwana147

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2024-04-16 18:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found