Skip to content

Conversation

@xezon
Copy link

@xezon xezon commented Dec 7, 2025

Merge with Rebase

This change removes superfluous AsciiString allocations for name key lookups. It was applied by hand. It is split into 2 commits for a cleaner file diff.

It cuts many allocations and can help loading and runtime performance a bit.

Adjacent to Name Key, some functions that did Name Key lookups and do not necessarily need to be given an AsciiString have been given a new function overload taking const char*.

The identified and affected functions are:

  • DamageFXStore::findDamageFX
  • UpgradeCenter::findUpgrade
  • ImageCollection::findImageByName
  • ArmorStore::findArmorTemplate
  • WeaponStore::findWeaponTemplate

There are probably plenty more functions of this kind but this change is already large enough as is and this seemed to be all directly related to Name Key things.

TODO

  • Replicate in Generals
  • Add pull id to commits

@xezon xezon added Minor Severity: Minor < Major < Critical < Blocker Performance Is a performance concern Gen Relates to Generals ZH Relates to Zero Hour Refactor Edits the code with insignificant behavior changes, is never user facing labels Dec 7, 2025
#include "Common/AsciiString.h"

//-------------------------------------------------------------------------------------------------
/**

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a particular reason why removing /**? A quick search yields its applied over 9,000 in the code. Do we want to fix it everywhere?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am in favor of replacing all block comments with inline comments. It caused syntax coloring issues in Visual Studio.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've created a task for that.

Copy link

@Skyaero42 Skyaero42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks all good to me

void load( Int textureSize ); ///< load images

const Image *findImageByName( const AsciiString& name ); ///< find image based on name
const Image *findImageByName( const AsciiString& name ) const; ///< find image based on name
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks wrong in isolation. Would make first commit fail compile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Gen Relates to Generals Minor Severity: Minor < Major < Critical < Blocker Performance Is a performance concern Refactor Edits the code with insignificant behavior changes, is never user facing ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants