Improve performance and code readibility#78
Merged
Nyeriah merged 10 commits intoazerothcore:masterfrom Feb 15, 2026
Merged
Conversation
…helper, fix double lookups, fix operator[] insertions, remove dead code Co-authored-by: Nyeriah <47818697+Nyeriah@users.noreply.github.com>
…rns in OnAllCreatureUpdate, fix double lookups, remove dead code Co-authored-by: Nyeriah <47818697+Nyeriah@users.noreply.github.com>
Co-authored-by: Nyeriah <47818697+Nyeriah@users.noreply.github.com>
Co-authored-by: Nyeriah <47818697+Nyeriah@users.noreply.github.com>
…adability Performance and readability overhaul
Contributor
There was a problem hiding this comment.
Pull request overview
This PR reduces per-tick overhead and map growth in the zone difficulty module by replacing operator[] reads with find()-based access patterns, flattening control flow, and removing dead debug/comment blocks.
Changes:
- Added
ZoneDifficulty::IsInstanceMythic()and replaced read-onlyMythicmodeInstanceData[instanceId]access to avoid accidental inserts. - Reduced redundant map lookups and nesting in several hot paths (heal/damage modifiers, creature update tick, instance encounter hooks).
- Cleaned up dead debug logging/comment blocks and simplified gossip handlers.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| src/mod_zone_difficulty_scripts.cpp | Reworks hot-path hooks to avoid operator[] insertions/double lookups, adds early-outs, and cleans dead debug code. |
| src/mod_zone_difficulty_handler.cpp | Adds IsInstanceMythic(), rewrites lookups to iterator-based access, and refactors phase/override checks. |
| src/ZoneDifficulty.h | Exposes IsInstanceMythic() and updates helper signatures for safer/cheaper calls. |
| .gitignore | Ignores CodeQL detected source root marker file. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…d hoist loop-invariant lookup Co-authored-by: Nyeriah <47818697+Nyeriah@users.noreply.github.com>
Fix OverrideModeMatches global override bug, eliminate redundant lookups, and minor cleanups
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Module is heavy on per-tick overhead and the code is cluttered with dead debug comments, redundant map lookups, and deep nesting.
MythicmodeInstanceDatamap bloatEvery read via
operator[]silently inserts a default entry for missing keys, growing the map unboundedly:Added
IsInstanceMythic()helper usingfind(), replaced all ~12 read-only accesses.OnAllCreatureUpdate— runs every tick for every creatureGetCreatureBaseStats/GenerateHealth)GetMaxHealth() == scaledHealthcomputing 3 modifier values) with directBASE_VALUEcomparisonCreatureOverrides.find()instead of find-then-bracket double lookupDouble map lookups throughout hot paths
Replaced
find() != end()followed byoperator[]with single iterator-based access in all damage/heal modifier hooks,OverrideModeMatches,HasCompletedFullTier,SaveMythicmodeInstanceData,GetLowestMatchingPhase,OnPlayerLogin, etc.Other fixes
VectorContainsUint32now takesconst std::vector<uint32>&instead of by valueShouldNerfInDuels()result where it was called twice inModifyHealReceivedOnInstanceIdRemoved: removed redundant find-before-erase (erase on missing key is a no-op)OverrideModeMatches: rewrote to usefind()for bothSpellNerfOverridesandMythicmodeInstanceDatainstead ofoperator[]Readability
LOG_INFOlines and/* debug ... end debug */blocksif (IsDebugInfoEnabled) { /* only comments */ }blocksModifyHealReceived,OnAfterUpdateEncounterStatesZoneDifficulty->NerfInfo[mapId][matchingPhase].SpellDamageBuffPct✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.