The only way I found to avoid this was to set the length outside the loop and update the array values by index. That was on the order of 10x faster.
relative benefit of .reserve and .length
Jay Norwood via Digitalmars-d-learn Thu, 28 Apr 2016 06:01:07 -0700
I timed some code recently and found that .reserve made almost no
improvement when appending. It appears that the actual change to
the length by the append had a very high overhead of something
over 200 instructions executed, regardless if the .reserve was
done. This was a simple append to an integer array.
- relative benefit of .reserve ... Jay Norwood via Digitalmars-d-learn
- Re: relative benefit of ... Basile B. via Digitalmars-d-learn
- Re: relative benefit... Steven Schveighoffer via Digitalmars-d-learn
- Re: relative benefit of ... Steven Schveighoffer via Digitalmars-d-learn
- Re: relative benefit... sigod via Digitalmars-d-learn
- Re: relative ben... Jay Norwood via Digitalmars-d-learn
- Re: relative ben... Steven Schveighoffer via Digitalmars-d-learn
- Re: relative... Eto Demerzel via Digitalmars-d-learn
- Re: rel... Steven Schveighoffer via Digitalmars-d-learn