←back to thread

Indices, not Pointers

(joegm.github.io)
102 points vitalnodo | 1 comments | | HN request time: 0s | source
Show context
nielsbot ◴[] No.45112577[source]
Wonder how this compares to combining pointers with indices (effectively):

Allocate your nodes in contiguous memory, but use pointers to refer to them instead of indices. This would remove an indirect reference when resolving node references: dereference vs (storage_base_address + element_size * index) Resizing your storage does become potentially painful: you have to repoint all your inter-node pointers. But maybe an alternative there is to just add another contiguous (memory page-sized?) region for more nodes.

Lots of trade offs to consider :)

replies(1): >>45112814 #
munch117 ◴[] No.45112814[source]
You have just reinvented the slab allocator.
replies(1): >>45116881 #
1. nielsbot ◴[] No.45116881[source]
Sure—-But I was specifically thinking in the context of this article