Browse Source

improve performance of arrays

Kolja Strohm 6 months ago
parent
commit
6720624bf3
1 changed files with 4 additions and 4 deletions
  1. 4 4
      Array.h

+ 4 - 4
Array.h

@@ -407,13 +407,12 @@ namespace Framework
         void leeren()
         {
             ArrayEintrag<TYP>* e2 = 0;
-            for (ArrayEintrag<TYP>* e = entries; e; e = e->next)
+            for (ArrayEintrag<TYP>* e = entries->next; e; e = e->next)
             {
                 delete e2;
                 e2 = e;
             }
             delete e2;
-            entries = new ArrayEintrag<TYP>();
             entries->set = 0;
             entries->next = 0;
             last = entries;
@@ -710,14 +709,15 @@ namespace Framework
         //! Löscht alle Elemente der Liste
         void leeren()
         {
-            for (ArrayEintrag<TYP*>* e = entries; e;)
+            for (ArrayEintrag<TYP*>* e = entries->next; e;)
             {
                 if (e && e->var && e->set) e->var->release();
                 auto tmp = e->next;
                 delete e;
                 e = tmp;
             }
-            entries = new ArrayEintrag<TYP*>();
+            if (entries && entries->var && entries->set)
+                entries->var->release();
             entries->set = 0;
             entries->next = 0;
             last = entries;