3 ms·
Counterpoint to people suggesting size_t for capacity: we recently changed our in-house std::vector replacement from { T* first, last, end; } to { T* first; u32
by shaggie76 4y ago
Counterpoint to people suggesting size_t for capacity: we recently changed our in-house std::vector replacement from { T* first, last, end; } to { T* first; u32 size, capacity; }.
Not only did this shave 8 bytes off of each instance but in many cases it saved more because they became 16 bytes which reduced alignment padding in other objects that use SIMD types that require 16-byte alignment.
This saved 40 MB of memory for us in https://warframe.fandom.com/wiki/Orb_Vallis https://warframe.fandom.com/wiki/Orb_Vallis which, given the poverty our mobile minspec, was a terrific savings.
Your needs may vary, but it's 2023 we're still cramming 4GB of poop into a 2GB bag.
- andrewmcwatters 4y agoIn game development, you'll want to do things like this often, but general purpose programming shouldn't adopt this practice. It's literally what the type is for.