2 ms·
As a lowly web developer I must not know what i'm missing, can anyone explain what the issue is with an array being a list of references? Why is there a chase g
by jazzyjackson 3y ago
As a lowly web developer I must not know what i'm missing, can anyone explain what the issue is with an array being a list of references? Why is there a chase going on, is someone trying to get away?
> JavaScript is... You think you have an array of objects, but you really have an array of pointers to objects. So every single time you're walking over that, you're chasing it down.
- taspeotis 3y agoPointer chasing, bad for cache locality.
- jazzyjackson 3y agoah, that closes the loop for me, thanks
- qwertox 3y agoI think it refers to the fact that you can't just compute an offset from element 0 to get to an element N, like you could if you'd have an array of structs or classes. Assume a struct uses up 128 bytes, then you can get to element N by using a pointer of N * 128 and you'd be positioned directly at the memory location of that struct. - Edit: cache locality like sibling comment mentions sounds more convincing.