title: How do you pre-size an array in Lua?
body: <p>I've got a Lua program that seems to be slower than it ought to be.  I suspect the issue is that I'm adding values to an associative array one at a time and the table has to allocate new memory each time.  </p>
  
  <p>There did seem to be a table.setn function, but it fails under Lua 5.1.3:</p>
  
  <pre><code>stdin:1: 'setn' is obsolete
  stack traceback:
          [C]: in function 'setn'
          stdin:1: in main chunk
          [C]: ?
  </code></pre>
  
  <p>I gather from the Google searching I've done that this function was depreciated in Lua 5.1, but I can't find what (if anything) replaced the functionality.</p>
  
  <p>Do you know how to pre-size a table in Lua?</p>
  
  <p>Alternatively, is there some other way to avoid memory allocation when you add an object to a table?</p>