There are several improvements I can think of at the moment to make the game run faster and use much less memory (it's already fairly low, but efficiency is key when we think of the game running on mobile devices and single threaded web browsers running 50 other tabs).
'
[ ] Changing all Vec::new statements to Vec::with_capacity should be fairly easy, and stop unnecessary memory allocs
[ ] Removing all or as many as possible Copy and Clone traits should make it so we're forced to use references whenever possible, instead of copying large amounts of memory. For stuff like Colors, this is fine since it's only copying a few bytes, so it has a fairly low priority, but for stuff like Maps, or Players, they use enough memory to where we should probably care (though Players is only around 1KB)
More should be added, I just can't think of any off of the top of my head. @Susorodni, if you could do the Vec::with_capacity thinkg I'd greatly appreciate it. Just have the capacity as however big you think the vec could be at max. Worst case scenario it just does another heap allocation which isn't a big deal.
Gonna close this to be honest. At the moment, work is focused on porting to Bevy, and I don't think a whole issue is needed just for replacing all Vec::new with Vec::with_capacity
There are several improvements I can think of at the moment to make the game run faster and use much less memory (it's already fairly low, but efficiency is key when we think of the game running on mobile devices and single threaded web browsers running 50 other tabs). '
Vec::new
statements toVec::with_capacity
should be fairly easy, and stop unnecessary memory allocsCopy
andClone
traits should make it so we're forced to use references whenever possible, instead of copying large amounts of memory. For stuff likeColors
, this is fine since it's only copying a few bytes, so it has a fairly low priority, but for stuff likeMaps
, orPlayers
, they use enough memory to where we should probably care (though Players is only around 1KB)More should be added, I just can't think of any off of the top of my head. @Susorodni, if you could do the Vec::with_capacity thinkg I'd greatly appreciate it. Just have the capacity as however big you think the vec could be at max. Worst case scenario it just does another heap allocation which isn't a big deal.