From e77d53fd418c14bfc9323a3fba1f45f93740b171 Mon Sep 17 00:00:00 2001 From: John Gross Date: Sat, 6 Jul 2019 17:18:15 -0700 Subject: [PATCH] Better SortedView fix --- Torch/Collections/SortedView.cs | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/Torch/Collections/SortedView.cs b/Torch/Collections/SortedView.cs index d76fa5e..3a8484c 100644 --- a/Torch/Collections/SortedView.cs +++ b/Torch/Collections/SortedView.cs @@ -110,19 +110,12 @@ namespace Torch.Collections public void Refresh() { - //HACK, fix the multithreading - try - { - _store.Clear(); - _store.AddRange(_backing); - Sort(); - } - catch (IndexOutOfRangeException e) - { - _log.Error(e); - Thread.Sleep(10); - Refresh(); - } + _store.Clear(); + //_store.AddRange(_backing); + _store.EnsureCapacity(_backing.Count); + foreach (var e in _backing) + _store.Add(e); + Sort(); } public void SetComparer(IComparer comparer, bool resort = true)