Hi Joshua. Thanks for taking the time to submit this.
The reason layout does not already have a user pointer in the items is that the user is meant to relate the items with their own data by using the ID/index of the item. layouts item IDs are contiguous in the order they are created, so you can simply allocate an array with the same count as the number of items you have, and put your user pointers at the associated indices.
By adding a user pointer to the item data struct, it increases the size of each item from 24 bytes to 32 bytes (on 64-bit, 28 bytes on 32-bit) and increases the alignment requirement from 4 bytes to 8 bytes (on 64-bit). Because most users will not use the user pointers, this ends up as entirely wasted space and memory bandwidth.
Hi Joshua. Thanks for taking the time to submit this.
The reason
layout
does not already have a user pointer in the items is that the user is meant to relate the items with their own data by using the ID/index of the item.layout
s item IDs are contiguous in the order they are created, so you can simply allocate an array with the same count as the number of items you have, and put your user pointers at the associated indices.By adding a user pointer to the item data struct, it increases the size of each item from 24 bytes to 32 bytes (on 64-bit, 28 bytes on 32-bit) and increases the alignment requirement from 4 bytes to 8 bytes (on 64-bit). Because most users will not use the user pointers, this ends up as entirely wasted space and memory bandwidth.