ComputerCraft ID allocation
Players discuss optimal ID allocation strategies in ComputerCraft, debating the tradeoffs between incrementing IDs and reusing old IDs from deallocated peripherals, especially regarding performance and memory.
- Using incrementing IDs (O(1)) is generally preferred over searching for reusable IDs (O(n)) due to performance, but a conscious tradeoff might be made if the performance impact isn't noticeable.
- Storing a list of reusable IDs would consume less memory than storing a list of active IDs, and an optimal implementation would use a bitfield over u64s.
- Using larger integer types like u64 or i64 for IDs would prevent overflow issues even if IDs are spammed, making the method of allocation less critical.
- Incrementing IDs are more robust to incorrect deallocations (e.g., due to chunk loading issues) as they simply assign a new ID, whereas reusing IDs requires tracking removed IDs reliably.


