Enum.ToString() was eating up a lot of time in IncomingPacketHandler()

This commit is contained in:
cinder
2025-05-29 13:03:28 -05:00
parent 79ef88c255
commit 88e4eb6d2e
2 changed files with 14 additions and 4 deletions

View File

@@ -1190,8 +1190,8 @@ namespace OpenMetaverse
private readonly Dictionary<LoginResponseCallback, string[]> CallbackOptions = new Dictionary<LoginResponseCallback, string[]>();
/// <summary>A list of packets obtained during the login process which
/// networkmanager will log but not process</summary>
private readonly List<string> UDPBlacklist = new List<string>();
/// NetworkManager will log but not process</summary>
private readonly List<PacketType> UDPBlacklist = new List<PacketType>();
#endregion
#region Public Methods
@@ -1764,7 +1764,17 @@ namespace OpenMetaverse
* for exclusion from packet processing */
if (reply.UDPBlacklist != null)
{
UDPBlacklist.AddRange(reply.UDPBlacklist.Split(','));
foreach (var entry in reply.UDPBlacklist.Split(','))
{
if (Enum.TryParse<PacketType>(entry, true, out var result))
{
UDPBlacklist.Add(result);
}
else
{
Logger.Log($"Could not parse {entry} from UDP Blacklist", Helpers.LogLevel.Warning);
}
}
}
// Misc:

View File

@@ -1023,7 +1023,7 @@ namespace OpenMetaverse
if (packet == null) continue;
// Skip blacklisted packets
if (UDPBlacklist.Contains(packet.Type.ToString()))
if (UDPBlacklist.Contains(packet.Type))
{
Logger.Log($"Discarding Blacklisted packet {packet.Type} from {simulator.IPEndPoint}",
Helpers.LogLevel.Warning);