forked from electronicarts/CnC_Generals_Zero_Hour
-
Notifications
You must be signed in to change notification settings - Fork 84
Labels
InvestigateMinorSeverity: Minor < Major < Critical < BlockerSeverity: Minor < Major < Critical < BlockerPerformanceIs a performance concernIs a performance concern
Description
- Allocates a new string on every call.
- Uses if condition instead of switch case. Unclear if the compiler will make it nice.
AsciiString GameMessage::getCommandTypeAsAsciiString(GameMessage::Type t)
{
#define CHECK_IF(x) if (t == x) { return #x; }
AsciiString commandName = "UnknownMessage";
if (t >= GameMessage::MSG_COUNT)
{
commandName = "Invalid command";
}
CHECK_IF(MSG_INVALID)
CHECK_IF(MSG_FRAME_TICK)
CHECK_IF(MSG_RAW_MOUSE_BEGIN)
CHECK_IF(MSG_RAW_MOUSE_POSITION)
CHECK_IF(MSG_RAW_MOUSE_LEFT_BUTTON_DOWN)
CHECK_IF(MSG_RAW_MOUSE_LEFT_DOUBLE_CLICK)
CHECK_IF(MSG_RAW_MOUSE_LEFT_BUTTON_UP)
CHECK_IF(MSG_RAW_MOUSE_LEFT_CLICK)
CHECK_IF(MSG_RAW_MOUSE_LEFT_DRAG)
...
// hundreds more
Metadata
Metadata
Assignees
Labels
InvestigateMinorSeverity: Minor < Major < Critical < BlockerSeverity: Minor < Major < Critical < BlockerPerformanceIs a performance concernIs a performance concern