- 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:
parent
602ea8f723
commit
3448749de6
10 changed files with 60 additions and 39 deletions
10
src/tarray.h
10
src/tarray.h
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue