Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trivial: speedup npc::get_monster_faction #45423

Merged
merged 1 commit into from
Nov 15, 2020

Conversation

Aivean
Copy link
Contributor

@Aivean Aivean commented Nov 15, 2020

Summary

SUMMARY: Performance "speedup npc::get_monster_faction"

Purpose of change

Currently npc::get_monster_faction constructs string_id from raw string each time it's called.
This is an unnecessary waste of CPU time.

Describe the solution

Change faction_template::mon_faction type from std::string to mfaction_str_id. This avoids on-demand string_id creation and saves some memory.

Describe alternatives you've considered

None.

Testing

Checked that game compiles and loads.

Additional context

Note: profiled on top of #45376 for full effect (generic factory caches is_valid lookups).

Before:
image

After:
image

@Aivean Aivean added [C++] Changes (can be) made in C++. Previously named `Code` Code: Performance Performance boosting code (CPU, memory, etc.) NPC / Factions NPCs, AI, Speech, Factions, Ownership labels Nov 15, 2020
@ZhilkinSerg ZhilkinSerg merged commit 18400b1 into CleverRaven:master Nov 15, 2020
@Aivean Aivean mentioned this pull request Nov 19, 2020
@Aivean Aivean deleted the npc-monfaction-speedup branch November 21, 2020 01:51
scarf005 added a commit to scarf005/Cataclysm-BN that referenced this pull request Aug 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code` Code: Performance Performance boosting code (CPU, memory, etc.) NPC / Factions NPCs, AI, Speech, Factions, Ownership
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants