Memory management hygiene: Use compare() instead of substr(), and put a few more things intrinsically in the memory pool.
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@23467 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
parent
3afe67dcc2
commit
4c70685382
10 changed files with 45 additions and 41 deletions
|
|
@ -150,20 +150,8 @@ struct TTypeLoc {
|
|||
};
|
||||
typedef TVector<TTypeLoc> TTypeList;
|
||||
|
||||
inline TTypeList* NewPoolTTypeList()
|
||||
{
|
||||
void* memory = GetThreadPoolAllocator().allocate(sizeof(TTypeList));
|
||||
return new(memory) TTypeList;
|
||||
}
|
||||
|
||||
typedef TVector<TString*> TIdentifierList;
|
||||
|
||||
inline TIdentifierList* NewPoolTIdentifierList()
|
||||
{
|
||||
void* memory = GetThreadPoolAllocator().allocate(sizeof(TIdentifierList));
|
||||
return new(memory) TIdentifierList;
|
||||
}
|
||||
|
||||
//
|
||||
// TODO: memory: TArraySizes can be replaced by something smaller.
|
||||
// Almost all arrays could be handled by two sizes each fitting
|
||||
|
|
@ -175,6 +163,8 @@ inline TIdentifierList* NewPoolTIdentifierList()
|
|||
// is used, it will be containing at least one size.
|
||||
|
||||
struct TArraySizes {
|
||||
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
|
||||
|
||||
TArraySizes() : maxArraySize(0) { }
|
||||
int getSize() { return sizes.front(); } // TArraySizes only exists if there is at least one dimension
|
||||
void setSize(int s) { sizes.push_back(s); }
|
||||
|
|
@ -185,12 +175,6 @@ protected:
|
|||
int maxArraySize; // for tracking maximum referenced index, before an explicit size is given
|
||||
};
|
||||
|
||||
inline TArraySizes* NewPoolTArraySizes()
|
||||
{
|
||||
void* memory = GetThreadPoolAllocator().allocate(sizeof(TArraySizes));
|
||||
return new(memory) TArraySizes;
|
||||
}
|
||||
|
||||
//
|
||||
// TPublicType (coming up after some dependent declarations)
|
||||
// is a workaround for a problem with the yacc stack, It can't have
|
||||
|
|
@ -484,12 +468,12 @@ public:
|
|||
shallowCopy(copyOf);
|
||||
|
||||
if (arraySizes) {
|
||||
arraySizes = NewPoolTArraySizes();
|
||||
arraySizes = new TArraySizes;
|
||||
*arraySizes = *copyOf.arraySizes;
|
||||
}
|
||||
|
||||
if (structure) {
|
||||
structure = NewPoolTTypeList();
|
||||
structure = new TTypeList;
|
||||
TStructureMapIterator iter;
|
||||
for (unsigned int i = 0; i < copyOf.structure->size(); ++i) {
|
||||
TTypeLoc typeLoc;
|
||||
|
|
@ -604,7 +588,7 @@ public:
|
|||
void setArraySizes(TArraySizes* s)
|
||||
{
|
||||
// For when we don't want distinct types sharing the same descriptor.
|
||||
arraySizes = NewPoolTArraySizes();
|
||||
arraySizes = new TArraySizes;
|
||||
*arraySizes = *s;
|
||||
}
|
||||
void setArraySizes(const TType& type) { setArraySizes(type.arraySizes); }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue