mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-16 21:24:58 +00:00
pef: Micro-optimizations to LogItem and IcdXmlAttribute equality
This commit is contained in:
@@ -7,7 +7,7 @@ namespace ICD.Common.Utils.Services.Logging
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Log Entry Item
|
/// Log Entry Item
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public struct LogItem
|
public struct LogItem : IEquatable<LogItem>
|
||||||
{
|
{
|
||||||
private readonly string m_Message;
|
private readonly string m_Message;
|
||||||
private readonly eSeverity m_Severity;
|
private readonly eSeverity m_Severity;
|
||||||
@@ -93,7 +93,14 @@ namespace ICD.Common.Utils.Services.Logging
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static bool operator !=(LogItem a1, LogItem a2)
|
public static bool operator !=(LogItem a1, LogItem a2)
|
||||||
{
|
{
|
||||||
return !(a1 == a2);
|
return !a1.Equals(a2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Equals(LogItem other)
|
||||||
|
{
|
||||||
|
return m_Severity == other.m_Severity &&
|
||||||
|
m_Timestamp == other.m_Timestamp &&
|
||||||
|
m_Message == other.m_Message;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -103,10 +110,7 @@ namespace ICD.Common.Utils.Services.Logging
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public override bool Equals(object other)
|
public override bool Equals(object other)
|
||||||
{
|
{
|
||||||
if (other == null || GetType() != other.GetType())
|
return other is LogItem && Equals((LogItem)other);
|
||||||
return false;
|
|
||||||
|
|
||||||
return GetHashCode() == ((LogItem)other).GetHashCode();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
namespace ICD.Common.Utils.Xml
|
using System;
|
||||||
|
|
||||||
|
namespace ICD.Common.Utils.Xml
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// IcdXmlAttribute represents an attribute="value" pair from xml.
|
/// IcdXmlAttribute represents an attribute="value" pair from xml.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public struct IcdXmlAttribute
|
public struct IcdXmlAttribute : IEquatable<IcdXmlAttribute>
|
||||||
{
|
{
|
||||||
private readonly string m_Name;
|
private readonly string m_Name;
|
||||||
private readonly string m_Value;
|
private readonly string m_Value;
|
||||||
@@ -41,7 +43,13 @@
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static bool operator !=(IcdXmlAttribute a1, IcdXmlAttribute a2)
|
public static bool operator !=(IcdXmlAttribute a1, IcdXmlAttribute a2)
|
||||||
{
|
{
|
||||||
return !(a1 == a2);
|
return !a1.Equals(a2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Equals(IcdXmlAttribute other)
|
||||||
|
{
|
||||||
|
return m_Name == other.m_Name &&
|
||||||
|
m_Value == other.m_Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -51,10 +59,7 @@
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public override bool Equals(object other)
|
public override bool Equals(object other)
|
||||||
{
|
{
|
||||||
if (other == null || GetType() != other.GetType())
|
return other is IcdXmlAttribute && Equals((IcdXmlAttribute)other);
|
||||||
return false;
|
|
||||||
|
|
||||||
return GetHashCode() == ((IcdXmlAttribute)other).GetHashCode();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user