Micro-optimization

This commit is contained in:
Chris Cameron
2018-03-05 14:08:00 -05:00
parent 421a3533db
commit 5eff7bdb6c

View File

@@ -243,6 +243,21 @@ namespace ICD.Common.Utils
return (T)Enum.ToObject(typeof(T), output);
}
/// <summary>
/// Gets the overlapping values of the given enum flags.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="a"></param>
/// <param name="b"></param>
/// <returns></returns>
public static T GetFlagsIntersection<T>(T a, T b)
{
int aInt = (int)(object)a;
int bInt = (int)(object)b;
return (T)Enum.ToObject(typeof(T), aInt & bInt);
}
/// <summary>
/// Gets all of the set flags on the given enum.
/// </summary>