mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-05 00:49:09 +02:00
Reduce size of Bonus struct from 320 bytes to 296 bytes.
- Internal enums were resized to occupy single byte. - Duration bitmask uses 16 bit integer directly instead of std::bitset<11> which consumed 8 bytes. - Fields shuffled to minimise padding and keep the most useful data on first 2 cache lines.
This commit is contained in:
@ -60,10 +60,11 @@ namespace BonusDuration
|
||||
JsonNode toJson(const Type & duration)
|
||||
{
|
||||
std::vector<std::string> durationNames;
|
||||
for(auto durBit = 0; durBit < duration.size(); durBit++)
|
||||
for(size_t durBit = 0; durBit < Size; durBit++)
|
||||
{
|
||||
if(duration[durBit])
|
||||
durationNames.push_back(vstd::findKey(bonusDurationMap, duration & Type().set(durBit)));
|
||||
Type value = duration & (1 << durBit);
|
||||
if(value)
|
||||
durationNames.push_back(vstd::findKey(bonusDurationMap, value));
|
||||
}
|
||||
if(durationNames.size() == 1)
|
||||
{
|
||||
|
Reference in New Issue
Block a user