perf(messages): mechanical interpolation cleanups (#2436)

## Summary

Phase 3.1 of the message-interpolation optimization series. Fixes 9 of the 28 sites flagged in the Phase 2 audit (PR #2435):

| File | Fix |
|---|---|
| `Commands/StaffAccess.cs:88,99` | Drop redundant `.ToString()` on enum holes |
| `Commands/Handlers.cs:102` | `builder.ToString()` -> `builder.AsSpan()` |
| `World Saves/SaveCommands.cs:71-75` | Merge 3 concatenated `$"..."` into one literal |
| `Server/Items/Item.cs:4213` | Hoist nested ternary `$"..."` to if/else |
| `Engines/Factions/Mobiles/Guards/BaseFactionGuard.cs:140-150` | Convert switch expression to switch statement |
| `Mobiles/Monsters/LBR/Jukas/JukaLord.cs:85` | Restructure `string.Format(toSay.RandomElement(), ...)` into switch |
| `Misc/AttackMessage.cs:30-41` | Inline `AggressorFormat`/`AggressedFormat` constants |

No functional changes. Each site emits identical text; the only difference is that the message string is now built into a pooled char buffer instead of being allocated as a `string` first.
This commit is contained in:
Kamron Batman 2026-05-03 18:26:49 -07:00 • committed by GitHub
parent 679e66b99d
commit b2ccc7e4f3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 53 additions and 21 deletions

View file

@ -4106,6 +4106,20 @@ public partial class Item : IHued, IComparable<Item>, ISpawnable, IObjectPropert
);
}
}
else if (m_Amount > 1)
{
ns.SendMessage(
Serial,
m_ItemID,
MessageType.Label,
0x3B2,
3,
false,
"ENU",
"",
$"{Name} : {m_Amount}"
);
}
else
{
ns.SendMessage(
@ -4117,7 +4131,7 @@ public partial class Item : IHued, IComparable<Item>, ISpawnable, IObjectPropert
false,
"ENU",
"",
$"{Name}{(m_Amount > 1 ? $" : {m_Amount}" : "")}"
$"{Name}"
);
}
}