From 130daf3e5e7dc02e1b2abc6244553314fd147eac Mon Sep 17 00:00:00 2001 From: rumkuhgel Date: Tue, 2 Jul 2019 02:38:14 +0200 Subject: [PATCH] Fix Clear method (#614) Make sure to clear the array before setting count to zero. --- Source/MonoGame.Extended/Collections/Bag.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/MonoGame.Extended/Collections/Bag.cs b/Source/MonoGame.Extended/Collections/Bag.cs index cfa59689..292c1d19 100644 --- a/Source/MonoGame.Extended/Collections/Bag.cs +++ b/Source/MonoGame.Extended/Collections/Bag.cs @@ -85,11 +85,11 @@ namespace MonoGame.Extended.Collections if(Count == 0) return; - Count = 0; - // non-primitive types are cleared so the garbage collector can release them if (!_isPrimitive) Array.Clear(_items, 0, Count); + + Count = 0; } public bool Contains(T element) @@ -191,4 +191,4 @@ namespace MonoGame.Extended.Collections } } } -} \ No newline at end of file +}