fix: Cleans up some string allocations from trim (#1759)
This commit is contained in:
parent
9d2f471e91
commit
d77668d77a
9 changed files with 15 additions and 22 deletions
|
|
@ -309,7 +309,7 @@ public static class AccountHandler
|
||||||
if (Accounts.GetAccount(un) is not Account acct)
|
if (Accounts.GetAccount(un) is not Account acct)
|
||||||
{
|
{
|
||||||
// To prevent someone from making an account of just '' or a bunch of meaningless spaces
|
// To prevent someone from making an account of just '' or a bunch of meaningless spaces
|
||||||
if (AutoAccountCreation && un.Trim().Length > 0)
|
if (AutoAccountCreation && !string.IsNullOrWhiteSpace(un))
|
||||||
{
|
{
|
||||||
e.State.Account = acct = CreateAccount(e.State, un, pw);
|
e.State.Account = acct = CreateAccount(e.State, un, pw);
|
||||||
e.Accepted = acct?.CheckAccess(e.State) ?? false;
|
e.Accepted = acct?.CheckAccess(e.State) ?? false;
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using ModernUO.Serialization;
|
using ModernUO.Serialization;
|
||||||
using Server.ContextMenus;
|
using Server.ContextMenus;
|
||||||
|
|
@ -287,7 +288,7 @@ public partial class BulkOrderBook : Item, ISecurable
|
||||||
|
|
||||||
if (from.CheckAlive() && m_Book.IsChildOf(from.Backpack))
|
if (from.CheckAlive() && m_Book.IsChildOf(from.Backpack))
|
||||||
{
|
{
|
||||||
m_Book.BookName = text.Trim().FixHtml();
|
m_Book.BookName = text.AsSpan().Trim().FixHtml();
|
||||||
|
|
||||||
from.SendLocalizedMessage(1062480); // The bulk order book's name has been changed.
|
from.SendLocalizedMessage(1062480); // The bulk order book's name has been changed.
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,13 +50,7 @@ namespace Server.Gumps
|
||||||
|
|
||||||
var g = m_List[i];
|
var g = m_List[i];
|
||||||
|
|
||||||
string name;
|
string name = g.Name?.Trim().DefaultIfNullOrEmpty("(empty)");
|
||||||
|
|
||||||
if ((name = g.Name) != null && (name = name.Trim()).Length <= 0)
|
|
||||||
{
|
|
||||||
name = "(empty)";
|
|
||||||
}
|
|
||||||
|
|
||||||
AddLabel(radio ? 55 : 20, 35 + i % 11 * 30, 0, name);
|
AddLabel(radio ? 55 : 20, 35 + i % 11 * 30, 0, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,13 +51,7 @@ namespace Server.Gumps
|
||||||
|
|
||||||
var m = m_List[i];
|
var m = m_List[i];
|
||||||
|
|
||||||
string name;
|
string name = m.Name?.Trim().DefaultIfNullOrEmpty("(empty)");
|
||||||
|
|
||||||
if ((name = m.Name) != null && (name = name.Trim()).Length <= 0)
|
|
||||||
{
|
|
||||||
name = "(empty)";
|
|
||||||
}
|
|
||||||
|
|
||||||
AddLabel(radio ? 55 : 20, 35 + i % 11 * 30, 0, name);
|
AddLabel(radio ? 55 : 20, 35 + i % 11 * 30, 0, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
using System;
|
||||||
using Server.Factions;
|
using Server.Factions;
|
||||||
using Server.Gumps;
|
using Server.Gumps;
|
||||||
using Server.Mobiles;
|
using Server.Mobiles;
|
||||||
|
|
@ -173,7 +174,7 @@ namespace Server.Guilds
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var charter = text.Trim().FixHtml();
|
var charter = text.AsSpan().Trim().FixHtml();
|
||||||
|
|
||||||
if (charter.Length > 50)
|
if (charter.Length > 50)
|
||||||
{
|
{
|
||||||
|
|
@ -193,7 +194,7 @@ namespace Server.Guilds
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var site = text.Trim().FixHtml();
|
var site = text.AsSpan().Trim().FixHtml();
|
||||||
|
|
||||||
if (site.Length > 50)
|
if (site.Length > 50)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
using System;
|
||||||
using Server.Gumps;
|
using Server.Gumps;
|
||||||
using Server.Mobiles;
|
using Server.Mobiles;
|
||||||
using Server.Network;
|
using Server.Network;
|
||||||
|
|
@ -265,7 +266,7 @@ namespace Server.Guilds
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var title = text.Trim().FixHtml();
|
var title = text.AsSpan().Trim().FixHtml();
|
||||||
|
|
||||||
if (title.Length > 20)
|
if (title.Length > 20)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -677,7 +677,7 @@ namespace Server.Guilds
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var name = text.Trim().FixHtml();
|
var name = text.AsSpan().Trim().FixHtml();
|
||||||
|
|
||||||
if (!CheckProfanity(name))
|
if (!CheckProfanity(name))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
using System;
|
||||||
using Server.Items;
|
using Server.Items;
|
||||||
using Server.Multis;
|
using Server.Multis;
|
||||||
using Server.Network;
|
using Server.Network;
|
||||||
|
|
@ -480,7 +481,7 @@ namespace Server.Gumps
|
||||||
|
|
||||||
if (m_Book.CheckAccess(from))
|
if (m_Book.CheckAccess(from))
|
||||||
{
|
{
|
||||||
m_Book.Description = text.Trim().FixHtml();
|
m_Book.Description = text.AsSpan().Trim().FixHtml();
|
||||||
|
|
||||||
from.CloseGump<RunebookGump>();
|
from.CloseGump<RunebookGump>();
|
||||||
from.SendGump(new RunebookGump(from, m_Book));
|
from.SendGump(new RunebookGump(from, m_Book));
|
||||||
|
|
|
||||||
|
|
@ -784,7 +784,8 @@ namespace Server.Multis
|
||||||
|
|
||||||
if (e.Speech.Length > 8)
|
if (e.Speech.Length > 8)
|
||||||
{
|
{
|
||||||
Rename(e.Speech[8..].Trim().DefaultIfNullOrEmpty(null));
|
var newName = e.Speech.AsSpan(8).Trim();
|
||||||
|
Rename(newName.Length == 0 ? null : newName.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue