0024911: Avoid using virtual functions in NCollection classes

NCollection_BaseCollection class, relevant header files, and macro DEFINE_BASECOLLECTION removed.
Hence methods Assign() from other compatible (via inheritance of BaseCollection) collections are not available any more, as well as base Iterator class.

All methods of Iterator classes are made non-virtual, allowing their inline expansion for better performance.

OCCT-specific operators new and delete added to collection classes and removed from iterator classes.
This commit is contained in:
abv
2014-05-08 09:13:00 +04:00
committed by apn
parent 598fcce93c
commit ddf2fe8eeb
66 changed files with 456 additions and 1016 deletions

View File

@@ -27,8 +27,7 @@ Standard_Boolean NCollection_BaseMap::BeginResize
(const Standard_Integer NbBuckets,
Standard_Integer& N,
NCollection_ListNode**& data1,
NCollection_ListNode**& data2,
Handle(NCollection_BaseAllocator)& theAllocator) const
NCollection_ListNode**& data2) const
{
if (mySaturated) return Standard_False;
N = NextPrimeForMap(NbBuckets);
@@ -39,12 +38,12 @@ Standard_Boolean NCollection_BaseMap::BeginResize
return Standard_False;
}
data1 = (NCollection_ListNode **)
theAllocator->Allocate((N+1)*sizeof(NCollection_ListNode *));
myAllocator->Allocate((N+1)*sizeof(NCollection_ListNode *));
memset(data1, 0, (N+1)*sizeof(NCollection_ListNode *));
if (isDouble)
{
data2 = (NCollection_ListNode **)
theAllocator->Allocate((N+1)*sizeof(NCollection_ListNode *));
myAllocator->Allocate((N+1)*sizeof(NCollection_ListNode *));
memset(data2, 0, (N+1)*sizeof(NCollection_ListNode *));
}
else
@@ -61,13 +60,12 @@ void NCollection_BaseMap::EndResize
(const Standard_Integer NbBuckets,
const Standard_Integer N,
NCollection_ListNode** data1,
NCollection_ListNode** data2,
Handle(NCollection_BaseAllocator)& theAllocator)
NCollection_ListNode** data2)
{
if (myData1)
theAllocator->Free(myData1);
myAllocator->Free(myData1);
if (myData2)
theAllocator->Free(myData2);
myAllocator->Free(myData2);
myNbBuckets = N;
mySaturated = (myNbBuckets <= NbBuckets);
myData1 = data1;
@@ -80,10 +78,8 @@ void NCollection_BaseMap::EndResize
//purpose :
//=======================================================================
void NCollection_BaseMap::Destroy
(NCollection_DelMapNode fDel,
Handle(NCollection_BaseAllocator)& theAllocator,
const Standard_Boolean doReleaseMemory)
void NCollection_BaseMap::Destroy (NCollection_DelMapNode fDel,
Standard_Boolean doReleaseMemory)
{
if (!IsEmpty())
{
@@ -98,7 +94,7 @@ void NCollection_BaseMap::Destroy
while (p)
{
q = (NCollection_ListNode*)p->Next();
fDel (p, theAllocator);
fDel (p, myAllocator);
p = q;
}
data[i] = NULL;
@@ -111,9 +107,9 @@ void NCollection_BaseMap::Destroy
{
mySaturated = Standard_False;
if (myData1)
theAllocator->Free(myData1);
myAllocator->Free(myData1);
if (isDouble && myData2)
theAllocator->Free(myData2);
myAllocator->Free(myData2);
myData1 = myData2 = NULL;
}
}