On Tuesday, 4 April 2023 at 22:20:52 UTC, H. S. Teoh wrote:

Best practices for arrays in hot loops:
- Avoid appending if possible; instead, pre-allocate outside the loop. - Where possible, reuse existing arrays instead of discarding old ones
  and allocating new ones.
- Use slices where possible instead of making copies of subarrays (this
  esp. applies to strings).
- Where possible, prefer sequential access over random access (take
  advantage of the CPU cache hierarchy).

Thanks for sharing Teoh!  Very helpful.

would this be random access? for(size_t i; i<arr.length; i++) using indices?
...and this be sequential foreach(a;arr) ?

or would they have to be completely different kinds of containers?
a dlang 'range' vs arr[]?


Reply via email to