Skip to content

Commit c53dfc8

Browse files
SubhikshaSf4851jfversluis
authored andcommitted
Modified the sample used HashSet
1 parent 606ba21 commit c53dfc8

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/Controls/src/Core/Handlers/Shell/Windows/ShellView.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,14 @@ internal void UpdateMenuItemSource()
123123
_flyoutGrouping = newGrouping;
124124
var newItems = IterateItems(newGrouping).ToList();
125125
var itemsCount = FlyoutItems.Count;
126+
var newItemsSet = new HashSet<object>(newItems);
127+
var flyoutItemsSet = new HashSet<object>(FlyoutItems);
126128

127129
for (int index = 0; index < newItems.Count; index++)
128130
{
129131
var item = newItems[index];
130132

131-
if (!FlyoutItems.Contains(item))
133+
if (!flyoutItemsSet.Contains(item))
132134
{
133135
// Use Insert when within bounds, otherwise Add
134136
if (index < itemsCount)
@@ -145,7 +147,7 @@ internal void UpdateMenuItemSource()
145147
for (var i = FlyoutItems.Count - 1; i >= 0; i--)
146148
{
147149
var item = FlyoutItems[i];
148-
if (!newItems.Contains(item))
150+
if (!newItemsSet.Contains(item))
149151
{
150152
FlyoutItems.RemoveAt(i);
151153
}

0 commit comments

Comments
 (0)