Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Re: Re: how can I speed up this perl??

by jbeninger (Monk)
on Nov 24, 2003 at 19:07 UTC ( #309636=note: print w/ replies, xml ) Need Help??


in reply to Re: Re: how can I speed up this perl??
in thread how can I speed up this perl??

Going a bit offtopic, how does the internal hash lookup compare to the array solution he has now? It seems to me that internally, Perl will be doing nearly the same thing - comparing the given key to each of the keys in the hash.


Comment on Re: Re: Re: how can I speed up this perl??
Re: Re: Re: Re: how can I speed up this perl??
by iburrell (Chaplain) on Nov 24, 2003 at 22:11 UTC
    The beauty of a hash is that Perl doesn't need to compare the string to every key in the hash. It computes the hash for the string and looks in the bucket for that hash. In a well balanced hash, there should only be one key in that hash. The string needs to be compared against the key(s) in the bucket.

    The hash replaces multiple comparisons with a hash calculation and usually one comparison.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (10)
As of 2014-07-25 02:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (167 votes), past polls