Skip to main content
Discovery icon for Minecraft Computer Mods Discord server

Minecraft Computer Mods

2,587 Online
7,347 Members
# computercraft3 people

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.
Summarized from recent messages, might be inaccurate

More conversations

Talk, Play, &
Hang Out

Find your space to hang out, discuss the latest updates with the party chat, and see who's down to join your next match.
Get App