3 ms·
> That only works if you allocate lists all at once and never modify them. You can reorder and modify the contents of the list without losing locality.
by wtetzner 4y ago
> That only works if you allocate lists all at once and never modify them.
You can reorder and modify the contents of the list without losing locality.
- duskwuff 4y agoI mean, if you modify the contents of the list nodes in place, sure. But at that point, you're just doing an array with extra steps. Changing any of the pointers, however, will make memory prefetch much less efficient. CPUs like linear memory access patterns; they're easy to predict. Chasing pointers is much less predictable, even if the pointers are all to the same region of memory.
- wtetzner 4y agoIt might still be cheaper than copying the values if they’re large.