News for hackers. Stuff that matters.
Re:In Defense of Linked Lists by wtetzner on Saturday November 05, 2022 @12:23AM (#33477945)
> 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.

Re:In Defense of Linked Lists by duskwuff on Saturday November 05, 2022 @01:09AM (#33478168)
I 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.

Re:In Defense of Linked Lists by wtetzner on Saturday November 05, 2022 @09:39AM (#33481359)
It might still be cheaper than copying the values if they’re large.