Uses iequatable over override equals to avoid conversion and checks at runtime

This commit is contained in:
Andy Adshead 2019-04-26 01:10:11 +01:00
commit 6c96712bfb

View file

@ -1,10 +1,8 @@
using System; using System;
using System.Collections.Generic;
using System.Text;
namespace Ryujinx.Profiler namespace Ryujinx.Profiler
{ {
public struct ProfileConfig public struct ProfileConfig : IEquatable<ProfileConfig>
{ {
public string Category; public string Category;
public string SessionGroup; public string SessionGroup;
@ -71,18 +69,12 @@ namespace Ryujinx.Profiler
} }
/// <summary> /// <summary>
/// This equals overload is vital
/// The default comparison is far too slow for the number of comparisons needed because it doesn't know what's important to compare /// The default comparison is far too slow for the number of comparisons needed because it doesn't know what's important to compare
/// </summary> /// </summary>
/// <param name="obj">Object to compare to</param> /// <param name="obj">Object to compare to</param>
/// <returns></returns> /// <returns></returns>
public override bool Equals(object obj) public bool Equals(ProfileConfig cmpObj)
{ {
if (!(obj is ProfileConfig))
return false;
ProfileConfig cmpObj = (ProfileConfig)obj;
// Order here is important. // Order here is important.
// Multiple entries with the same item is considerable less likely that multiple items with the same group. // Multiple entries with the same item is considerable less likely that multiple items with the same group.
// Likewise for group and category. // Likewise for group and category.