4 ms·
But this still takes 9 bytes (at least) to store a tagged uint8_t.
by masfuerte 3y ago
But this still takes 9 bytes (at least) to store a tagged uint8_t.
- kazinator 3y agoThe article's approach requires 8 bytes, plus a separate array of 1 byte tags. The article reduces it to 4 bytes, plus an array of 1 byte tags, by dropping the requirement for a 64 bit member. If we have to grow the array, we have to do two reallocations. Caching is worsened: the tag and content are going to be in separate cache lines.
- masfuerte 3y agoThe final approach in the article is an array for each unique object size plus tagged indices/pointers. This would take one byte per uint8_t and doesn't suffer from the problems you mention, though it does have others. If memory pressure is your main problem it's a big win.