in reply to Re^2: How do I efficiently predeclare a hash with a set of keys
in thread How do I efficiently predeclare a hash with a set of keys
Good call. At some point in the past, the undef version used less memory and was faster than the null list assignment version. If I remember correctly, it was tilly that pointed this out to me.
However, I just tried it with 5.8.8 and that is no longer the case. They both use the same amount of memory, and the null list assignment is marginally (~4%) faster. It's still faster and uses less memory than the typical method.
my %set = map{ $_ => 1 } 1, 2, 5..8, 100..200;
Another case of How do I know what I 'know' is right?. :( I'll update my node above to reflect this.
|
|---|