Codechange: Speed up industry generation using industry-type checks. (#13094)

Store a list of industries per industry type. This allows industry generation checks which only consider a specific industry type to check a reduced set of industries, leading to a potential performance increase.

This also removes the need to track industry type counts as well.
This commit is contained in:
Peter Nelson
2024-11-22 23:17:24 +00:00
committed by GitHub
parent a951896364
commit 16038879e4
5 changed files with 39 additions and 77 deletions

View File

@@ -211,7 +211,6 @@ struct INDYChunkHandler : ChunkHandler {
SlIndustryAccepted::ResetOldStructure();
SlIndustryProduced::ResetOldStructure();
Industry::ResetIndustryCounts();
while ((index = SlIterateArray()) != -1) {
Industry *i = new (index) Industry();
@@ -229,7 +228,7 @@ struct INDYChunkHandler : ChunkHandler {
} else if (IsSavegameVersionBefore(SLV_INDUSTRY_CARGO_REORGANISE)) {
LoadMoveAcceptsProduced(i, INDUSTRY_NUM_INPUTS, INDUSTRY_NUM_OUTPUTS);
}
Industry::IncIndustryTypeCount(i->type);
Industry::industries[i->type].push_back(i->index); // Assume savegame indices are sorted.
}
}