Keep It Simple, Stupid | |
PerlMonks |
Re: '%hash = ()' is slower than 'undef %hash'by dave_the_m (Monsignor) |
on May 18, 2018 at 12:37 UTC ( [id://1214844]=note: print w/replies, xml ) | Need Help?? |
For anything but small hashes, the total time will be dominated by the time to free all the hash elements (which uses the same code path for both methods). Other than that, the assign will generally have a slightly higher overhead as it has to create an empty list first. In perl 5.26.0, the actual list assign operator has been optimised so that it handles an empty RHS lists more efficiently.
Dave.
In Section
Seekers of Perl Wisdom
|
|