Skip to content

Commit

Permalink
code styling and perf improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
hansmbakker committed Oct 7, 2020
1 parent fe1f18a commit b601e57
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions Microsoft.Toolkit/Collections/ObservableGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ namespace Microsoft.Toolkit.Collections
[DebuggerDisplay("Key = {Key}, Count = {Count}")]
public class ObservableGroup<TKey, TValue> : ObservableCollection<TValue>, IGrouping<TKey, TValue>, IReadOnlyObservableGroup
{
private TKey key;
/// <summary>
/// The cached <see cref="PropertyChangedEventArgs"/> for <see cref="Key"/>
/// </summary>
private static readonly PropertyChangedEventArgs KeyChangedEventArgs = new PropertyChangedEventArgs(nameof(Key));

/// <summary>
/// Initializes a new instance of the <see cref="ObservableGroup{TKey, TValue}"/> class.
Expand Down Expand Up @@ -51,6 +54,8 @@ public ObservableGroup(TKey key, IEnumerable<TValue> collection)
Key = key;
}

private TKey key;

/// <summary>
/// Gets or sets the key of the group.
/// </summary>
Expand All @@ -62,8 +67,8 @@ public TKey Key
if (!EqualityComparer<TKey>.Default.Equals(this.key, value))
{
this.key = value;
OnPropertyChanged(new PropertyChangedEventArgs(nameof(Key)));

OnPropertyChanged(KeyChangedEventArgs);
}
}
}
Expand Down

0 comments on commit b601e57

Please sign in to comment.