feat(Core/Optimization): Create index for sSkillLineAbilityStore to speedup search by skillLine. (#18622)

* feat(Core/Optimization): Create index for sSkillLineAbilityStore to speedup search by skillLine.

* Remove whitespace.
This commit is contained in:
Anton Popovichenko
2024-04-01 10:50:12 +02:00
committed by GitHub
parent aee2eefb92
commit 47f9d66874
5 changed files with 24 additions and 32 deletions

View File

@@ -139,6 +139,7 @@ DBCStorage <ScalingStatValuesEntry> sScalingStatValuesStore(ScalingStatValuesfmt
DBCStorage <SkillLineEntry> sSkillLineStore(SkillLinefmt);
DBCStorage <SkillLineAbilityEntry> sSkillLineAbilityStore(SkillLineAbilityfmt);
SkillLineAbilityIndexBySkillLine sSkillLineAbilityIndexBySkillLine;
DBCStorage <SkillRaceClassInfoEntry> sSkillRaceClassInfoStore(SkillRaceClassInfofmt);
SkillRaceClassInfoMap SkillRaceClassInfoBySkill;
DBCStorage <SkillTiersEntry> sSkillTiersStore(SkillTiersfmt);
@@ -454,6 +455,9 @@ void LoadDBCStores(const std::string& dataPath)
}
}
for (SkillLineAbilityEntry const* skillLine : sSkillLineAbilityStore)
sSkillLineAbilityIndexBySkillLine[skillLine->SkillLine].push_back(skillLine);
// Create Spelldifficulty searcher
for (SpellDifficultyEntry const* spellDiff : sSpellDifficultyStore)
{
@@ -908,3 +912,14 @@ SkillRaceClassInfoEntry const* GetSkillRaceClassInfo(uint32 skill, uint8 race, u
return nullptr;
}
const std::vector<SkillLineAbilityEntry const*>& GetSkillLineAbilitiesBySkillLine(uint32 skillLine)
{
auto it = sSkillLineAbilityIndexBySkillLine.find(skillLine);
if (it == sSkillLineAbilityIndexBySkillLine.end())
{
static const std::vector<SkillLineAbilityEntry const*> emptyVector;
return emptyVector;
}
return it->second;
}

View File

@@ -72,6 +72,9 @@ typedef std::unordered_multimap<uint32, SkillRaceClassInfoEntry const*> SkillRac
typedef std::pair<SkillRaceClassInfoMap::iterator, SkillRaceClassInfoMap::iterator> SkillRaceClassInfoBounds;
SkillRaceClassInfoEntry const* GetSkillRaceClassInfo(uint32 skill, uint8 race, uint8 class_);
typedef std::unordered_map<uint32 /* SkillLine */, std::vector<SkillLineAbilityEntry const*> > SkillLineAbilityIndexBySkillLine;
const std::vector<SkillLineAbilityEntry const*>& GetSkillLineAbilitiesBySkillLine(uint32 skillLine);
extern DBCStorage <AchievementEntry> sAchievementStore;
extern DBCStorage <AchievementCriteriaEntry> sAchievementCriteriaStore;
extern DBCStorage <AchievementCategoryEntry> sAchievementCategoryStore;
@@ -151,6 +154,7 @@ extern DBCStorage <ScalingStatDistributionEntry> sScalingStatDistributionStore;
extern DBCStorage <ScalingStatValuesEntry> sScalingStatValuesStore;
extern DBCStorage <SkillLineEntry> sSkillLineStore;
extern DBCStorage <SkillLineAbilityEntry> sSkillLineAbilityStore;
extern SkillLineAbilityIndexBySkillLine sSkillLineAbilityIndexBySkillLine;
extern DBCStorage <SkillTiersEntry> sSkillTiersStore;
extern DBCStorage <SoundEntriesEntry> sSoundEntriesStore;
extern DBCStorage <SpellCastTimesEntry> sSpellCastTimesStore;