Actually make trait filter work and get rid of lots unnecessary allocation

This commit is contained in:
Dustin Campbell
2015-12-06 07:14:36 -08:00
parent f1879e1a06
commit dbbb6b3fad
5 changed files with 63 additions and 58 deletions
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
@@ -26,6 +27,20 @@ namespace xunit.runner.wpf.ViewModel
}
}
public TraitViewModel GetOrAdd(string text)
{
var index = this.Collection.BinarySearch(text, StringComparer.Ordinal, vm => vm.Text);
if (index < 0)
{
var viewModel = new TraitViewModel(text);
this.Collection.Insert(~index, viewModel);
return viewModel;
}
return this.Collection[index];
}
public ISet<TraitViewModel> GetCheckedTraits()
{
return new HashSet<TraitViewModel>(