diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-10-03 11:24:32 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-10-03 11:24:32 -0400 |
| commit | d021e20249c85ab96783e1347d95f826a816ff9b (patch) | |
| tree | d91ff481ab6617528c5be71b05496170d7d95d7b /MediaBrowser.Controller/Entities/LinkedChild.cs | |
| parent | 16fd474ad3e7d74cd78779350d2ee0ea7017f627 (diff) | |
improve shortcut performance
Diffstat (limited to 'MediaBrowser.Controller/Entities/LinkedChild.cs')
| -rw-r--r-- | MediaBrowser.Controller/Entities/LinkedChild.cs | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/MediaBrowser.Controller/Entities/LinkedChild.cs b/MediaBrowser.Controller/Entities/LinkedChild.cs index edc5a7ac8..e01d55c68 100644 --- a/MediaBrowser.Controller/Entities/LinkedChild.cs +++ b/MediaBrowser.Controller/Entities/LinkedChild.cs @@ -1,5 +1,6 @@ using System; -using System.Collections; +using System.Collections.Generic; +using System.Runtime.Serialization; namespace MediaBrowser.Controller.Entities { @@ -7,6 +8,12 @@ namespace MediaBrowser.Controller.Entities { public string Path { get; set; } public LinkedChildType Type { get; set; } + + /// <summary> + /// Serves as a cache + /// </summary> + [IgnoreDataMember] + public Guid ItemId { get; set; } } public enum LinkedChildType @@ -15,24 +22,20 @@ namespace MediaBrowser.Controller.Entities Shortcut = 2 } - public class LinkedChildComparer : IComparer + public class LinkedChildComparer : IEqualityComparer<LinkedChild> { - public int Compare(object x, object y) + public bool Equals(LinkedChild x, LinkedChild y) { - var a = (LinkedChild)x; - - var b = (LinkedChild)y; - - if (!string.Equals(a.Path, b.Path, StringComparison.OrdinalIgnoreCase)) + if (x.Type == y.Type) { - return string.Compare(a.Path, b.Path, StringComparison.OrdinalIgnoreCase); - } - if (a.Type != b.Type) - { - return a.Type.CompareTo(b.Type); + return string.Equals(x.Path, y.Path, StringComparison.OrdinalIgnoreCase); } + return false; + } - return 0; + public int GetHashCode(LinkedChild obj) + { + return (obj.Path + obj.Type.ToString()).GetHashCode(); } } } |
