Skip to content

Commit

Permalink
Merge branch 'main' into release/4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
acizmarik committed Mar 23, 2022
2 parents 00eed3b + 81a22df commit 6782e12
Showing 1 changed file with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -246,14 +246,32 @@ public void Add(KeyValuePair<string, TValue> item)

public void Clear()
{
// we want to avoid allocating the list if there is only one property
DotvvmProperty? toRemove = null;
List<DotvvmProperty>? toRemoveRest = null;

foreach (var (p, _) in control.properties)
{
var pg = p as GroupedDotvvmProperty;
if (pg != null && pg.PropertyGroup == group)
{
control.Properties.Remove(p);
if (toRemove is null)
toRemove = p;
else
{
if (toRemoveRest is null)
toRemoveRest = new List<DotvvmProperty>();
toRemoveRest.Add(p);
}
}
}

if (toRemove is {})
control.Properties.Remove(toRemove);

if (toRemoveRest is {})
foreach (var p in toRemoveRest)
control.Properties.Remove(p);
}

public bool Contains(KeyValuePair<string, TValue> item)
Expand Down

0 comments on commit 6782e12

Please sign in to comment.