- replaced a few temporary allocations with TArray and added a few convenience loader functions for this.

Amazingly with today's optimizers this creates code which is just as good as doing it all manually with the added benefit of being safer.
This commit is contained in:
Christoph Oelckers 2018-11-10 11:56:18 +01:00
commit 3448749de6
10 changed files with 60 additions and 39 deletions

View file

@ -157,12 +157,12 @@ public:
Count = 0;
Array = NULL;
}
TArray (int max, bool reserve = false)
TArray (size_t max, bool reserve = false)
{
Most = max;
Count = reserve? max : 0;
Most = (unsigned)max;
Count = (unsigned)(reserve? max : 0);
Array = (T *)M_Malloc (sizeof(T)*max);
if (reserve)
if (reserve && Count > 0)
{
ConstructEmpty(0, Count - 1);
}
@ -436,7 +436,7 @@ public:
Grow (amount);
unsigned int place = Count;
Count += amount;
ConstructEmpty(place, Count - 1);
if (Count > 0) ConstructEmpty(place, Count - 1);
return place;
}
unsigned int Size () const