From 79e60e670a92f86ce693c1b10076935346020b11 Mon Sep 17 00:00:00 2001 From: Anton Tarasenko Date: Fri, 5 Nov 2021 04:20:30 +0700 Subject: [PATCH] Fix not deallocating keys with `Empty()` `AssociativeArray` did not deallocate keys for non-managed items on `Empty()` call. --- sources/Data/Collections/AssociativeArray.uc | 22 ++++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/sources/Data/Collections/AssociativeArray.uc b/sources/Data/Collections/AssociativeArray.uc index 72a82cf..920a88a 100644 --- a/sources/Data/Collections/AssociativeArray.uc +++ b/sources/Data/Collections/AssociativeArray.uc @@ -514,23 +514,23 @@ public function Empty(optional bool deallocateKeys) { if (!nextEntries[j].managed) continue; if (nextEntries[j].value == none) continue; - if ( nextEntries[j].value.GetLifeVersion() - != nextEntries[j].valueLifeVersion) { - continue; - } - if (deallocateKeys) - { - subCollection = Collection(nextEntries[j].value); - if (subCollection != none) { - subCollection.Empty(true); - } - } nextEntries[j].value.FreeSelf(nextEntries[j].valueLifeVersion); } if (deallocateKeys) { for (j = 0; j < nextEntries.length; j += 1) { + if (nextEntries[j].key == none) { + continue; + } + if ( nextEntries[j].key.GetLifeVersion() + != nextEntries[j].keyLifeVersion) { + continue; + } + subCollection = Collection(nextEntries[j].value); + if (subCollection != none) { + subCollection.Empty(true); + } if (nextEntries[j].key != none) { nextEntries[j].key.FreeSelf(nextEntries[j].keyLifeVersion); }