Brian Helterline <> wrote:
> gf wrote:
>> Pass the hash as a reference for speed...
> You want speed...
>> ...a_option(\%hash_to_scan);
>> ...
>> sub a_option {
>>
>> # make sure you got a hash-ref and it contained something. This is
>> called defensive programming and is good for speed and robustness.
>> my $href = shift or return;
>> my %hash = %{$href};
> and then immediately dereference. Not much different than passing the
> hash.
It seems completely different to me. The reference is a constant
penalty to dereference. Otherwise, it's a penalty to copy the data. So
as the contents of the hash increase in size, the cost to copy
increases.
If the hash is sizeable (megabytes), the you're saving time and memory.
If the hash will always be tiny, then you're probably not saving
anything.
--
Darren Dunham
Senior Technical Consultant TAOS
http://www.taos.com/
Got some Dr Pepper? San Francisco, CA bay area
< This line left intentionally blank to confuse you. >