March 25, 2013 Re: Efficiency of using array as stack | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | > You will likely get better performance if you use: > > a ~= int.init; > > instead of: > > a.length++; So that's a relief, a dynamic array in D actually *is* an efficient queue implementation out of the box, I just did it improperly in the example. Thank you for the correction. With that, the number of relocations in the queue example dropped down to 2. > growth of 1024 is when the new pages are tacked onto the end (4096 / sizeof(int)), growth of 891 is interesting. I can explain it though :) Thank you for the very detailed explanation! Knowing how things work down to the bare bones, and the rationale behind that, is definitely helpful, both logically (to write better code) and psychologically (the feeling of things in control). I just hope such quality explanations will be incorporated into some book or manual someday. ----- Ivan Kazmenko. |
Copyright © 1999-2021 by the D Language Foundation