Skip to content

perf: Resources::GetDamagetypeImage takes its key by value and looks it up twice #2520

Description

@3vcloud

Found by a static pass with the new .agents/skills/performance-audit skill. Not measured.

Resources::GetDamagetypeImage (GWToolboxdll/Modules/Resources.cpp:964):

IDirect3DTexture9** Resources::GetDamagetypeImage(std::string dmg_type)   // by value -> allocation per call
{
    if (damagetype_icons.contains(dmg_type)) {
        return damagetype_icons.at(dmg_type);                             // second lookup on the hit path
    }

It is called per row, per frame from TargetInfoWindow::Draw (Windows/TargetInfoWindow.cpp:471), so the cache-hit path - which is every frame after the first - pays a std::string construction plus two hashed lookups.

Suggested fix: take std::string_view (or const std::string&) and resolve with a single find(). Worth checking the neighbouring Resources::Get*Image accessors for the same shape while in there (GetProfessionImage at Resources.cpp:929 does the same double lookup).

Activity

  1. added
    enhancementImprovement of an existing feature
    HousekeepingTidying up the mess that is our codebase.
    on Aug 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    HousekeepingTidying up the mess that is our codebase.enhancementImprovement of an existing feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions