diff --git a/source/Handlebars/Collections/DictionarySlim.cs b/source/Handlebars/Collections/DictionarySlim.cs index 3433e20a..d361f624 100644 --- a/source/Handlebars/Collections/DictionarySlim.cs +++ b/source/Handlebars/Collections/DictionarySlim.cs @@ -183,7 +183,10 @@ public void AddOrReplace(in TKey key, in TValue value) (uint)i < (uint)entries.Length; i = entries[i].Next) { if (_comparer.Equals(key, entries[i].Key)) + { entries[i].Value = value; + return; + } if (collisionCount == entries.Length) { // The chain of entries forms a loop; which means a concurrent update has happened. diff --git a/source/Handlebars/Collections/WeakCollection.cs b/source/Handlebars/Collections/WeakCollection.cs index 1b6d2bd5..e01ef1ef 100644 --- a/source/Handlebars/Collections/WeakCollection.cs +++ b/source/Handlebars/Collections/WeakCollection.cs @@ -13,6 +13,8 @@ public class WeakCollection : IEnumerable where T : class public void Add(T value) { + // Need a way to reset _firstAvailableIndex periodically + for (var index = _firstAvailableIndex; index < _store.Count; index++) { if (_store[index] == null) diff --git a/source/Handlebars/Pools/BindingContext.Pool.cs b/source/Handlebars/Pools/BindingContext.Pool.cs index 8fc6a999..7d616477 100644 --- a/source/Handlebars/Pools/BindingContext.Pool.cs +++ b/source/Handlebars/Pools/BindingContext.Pool.cs @@ -46,6 +46,8 @@ internal struct BindingContextPolicy : IInternalObjectPoolPolicy public bool Return(BindingContext item) { + item.Configuration = null; + item.Root = null; item.Value = null; item.ParentContext = null;