<?xml version="1.0" encoding="windows-1252"?>
<node id="862104" title="Re: Minimum Hash keys allocated?" created="2010-09-26 14:20:19" updated="2010-09-26 14:20:19">
<type id="11">
note</type>
<author id="747201">
afoken</author>
<data>
<field name="doctext">
&lt;p&gt;[http://en.wikipedia.org/wiki/Program_optimization#When_to_optimize|Premature optimization is the root of all evil]. Just don't do that. Perl will handle allocation good enough most of the times. There may be rare cases where preallocation may be useful, but then, you would use [mod://Devel::NYTProf] or similar first to find and eliminate other bottlenecks.&lt;/p&gt;
&lt;p&gt;To save keystrokes, use &lt;c&gt;my %hash=();&lt;/c&gt; or just &lt;c&gt;my %hash;&lt;/c&gt;, both are technically equal. Some people (including me) prefer the first form, refusing to rely on the implementation details of Perl to initialize the variable with an empty hash / empty array / undefined scalar, other people think that the documentation is very clear on this fact and the initializing assignment is just too much and redundant work.&lt;/p&gt;
&lt;p&gt;Alexander&lt;/p&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-747201"&gt;
--&lt;br&gt;
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
862100</field>
<field name="parent_node">
862100</field>
</data>
</node>
