Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>Max wrote :</p> <p>I have a zillion calls to a function which does one time SetLength( Result, Len ).</p> </blockquote> <p>Check on how you use your function : do you really need a zillion distinct calls to this allocating function ? can you, as Francois suggested, redesign your code to lower the number of calls ?</p> <p>If you really need one zillion distinct calls to your function, and need to speed things up, I think you will need to leave dynamic arrays and use a different structure.</p> <p>But before doing that, and enter a complete debugging hell, I would strongly join Francois suggestion, and try to redesign the code.</p> <p>Maybe you can tell us a bit more about your algorithm ? Is it about handling graphical 3D structures ?</p> <p>[EDIT] Ok, if it's about solving NP-complete problems, I would try to avoid allocating as much as possible.</p> <p>Most of the time, you can give an upper bound to the size of your arrays/stacks/structures - e.g : #cities, #vehicles + #drivers, #roads * #cities ...</p> <p>For those parts, I would suggest allocating once the biggest possible array, and handling manually the fact that you use only the first n rows or such.</p> <p>Given the computing time it can save afterwards, even allocating structures in n^2 or n^3 can be acceptable.</p> <p>Optimizing SetLength : what you suggest makes sense.</p> <p>However, if dynamic arrays are well adapted to writing Delphi code - mainly because of their "automatic constructor" semantics - they are, IMHO, not well adapted to high performance computations - it relies heavily on RTTI, reference counting can give you surprises every now and then...<br> What you are suggesting is a change in dynamic arrays semantics. Try to see if the solution "changing your data type" is really that impossible to write &amp; debug.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload