fix: Fixes and optimizes NameVerification and ProfanityProtection (#2153)

### Summary

Significantly improves the performance of NameVerification & ProfanityProtection:

```cs
| Method         | Mean      | Error     | StdDev    |
|--------------- |----------:|----------:|----------:|
| ValidateName   | 728.34 ns | 13.244 ns | 11.059 ns |
| ValidateNameSV |  26.62 ns |  0.233 ns |  0.207 ns |
```
This commit is contained in:
Kamron Batman 2025-04-12 02:26:10 -07:00 • committed by GitHub
parent 0ce2a62a76
commit a94814a7ef
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 624 additions and 440 deletions

View file

@ -1,3 +1,4 @@
using System;
using ModernUO.Serialization;
using Server.Gumps;
using Server.Misc;
@ -79,15 +80,15 @@ public class NameChangeDeedGump : Gump
var m = sender.Mobile;
var newName = info.GetTextEntry(0)?.Trim();
var newName = info.GetTextEntry(0).AsSpan().Trim();
if (!NameVerification.Validate(newName, 2, 16, true, false, true, 1, NameVerification.SpaceDashPeriodQuote))
if (!NameVerification.ValidatePlayerName(newName))
{
m.SendMessage("That name is unacceptable.");
return;
}
m.RawName = newName;
m.RawName = newName.ToString();
m.SendMessage("Your name has been changed!");
m.SendMessage($"You are now known as {newName}");
m_Sender.Delete();